Native Inspect Manual (H06.03+)

Table Of Contents
Using Tcl Scripting
Native Inspect Manual528122-003
4-3
Using Variables Defined in a Tcl Script
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:
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.