Native Inspect Manual (H06.13+, J06.03+)
• modify command
• reg command
• tn command
Loading a Tcl Script
To load a Tcl script, use the Tcl source command. For example, to run the script named myTcl,
enter:
(eInspect 3,301): tcl source myTcl
To run the script, enter the name of the Tcl script at the Native Inspect prompt.
Using Variables Defined in a Tcl Script
You can use variables defined in a Tcl script, such as $amount, after you run the Tcl script that
contains the definition.
The Tcl interpreter treats all command arguments as Tcl scripts. The Tcl environment is persistent
for each interactive session, so variables you create and values you set are retained. For example:
(eInspect 3,301): tcl set x 0xabcd
(eInspect 3,301): tcl puts $x
0xabcd
Programming Native Inspect Tcl Commands
The Tcl Style Guide (http://www.tcl.tk/doc/styleGuide.pdf) provides a structure for Tcl script
headers and the layout of package namespaces. The structure consists of the following:
• File header
Abstract◦
◦ Copyright notice
◦ Revision string
◦ Package definition (package name, namespace, version)
• Procedure headers (one or more)
Abstract◦
◦ Arguments
◦ Results
Namespaces and Package Loading Rules
Tcl supports packages and hierarchical namespaces.
Creating Packages
Packages are libraries of Tcl code that you can create using the Tcl package provide command:
# mySub.tcl
package provide mySub 1.0
# my package code
Putting a Package in a Namespace
The global namespace contains the built-in Tcl commands, such as set, puts, and open. You should
create your Tcl packages in your own child namespace, not in the global namespace, which should
be the exclusive property of the application.
For example, to put package code in a namespace, use the namespace eval command. This
example puts a package in a namespace of the same name:
130 Using Tcl Scripting










