Appendix a - tcl scripting – Sensoray 2224 Windows User Manual
Page 75

Appendix A - TCL Scripting
The 2226 Demo application includes a TCL scripting language interface. It is accessed from the Tools
menu. The version used is based on Jim Tcl. Jim Tcl is a small footprint reimplementation of the Tcl
scripting language. The core language engine is compatible with Tcl 8.5+, while implementing a
significant subset of the Tcl 8.6 command set, plus additional features available only in Jim Tcl.
Tcl stands for tool command language and is pronounced tickle. It is actually two things: a language and
a library.
First, Tcl is a simple textual language, intended primarily for issuing commands to interactive programs
such as text editors, debuggers, illustrators, and shells. It has a simple syntax and is also programmable,
so Tcl users can write command procedures to provide more powerful commands than those in the built-
in set.
Second, Tcl is a library package that can be embedded in application programs. The Tcl library consists
of a parser for the Tcl language, routines to implement the Tcl built-in commands, and procedures that
allow each application to extend Tcl with additional commands specific to that application. The
application program generates Tcl commands and passes them to the Tcl parser for execution.
Commands may be generated by reading characters from an input source, or by associating command
strings with elements of the application’s user interface, such as menu entries, buttons, or keystrokes.
When the Tcl library receives commands it parses them into component fields and executes built-in
commands directly. For commands implemented by the application, Tcl calls back to the application to
execute the commands. In many cases commands will invoke recursive invocations of the Tcl interpreter
by passing in additional strings to execute (procedures, looping commands, and conditional commands
all work in this way).
An application program gains three advantages by using Tcl for its command language. First, Tcl
provides a standard syntax: once users know Tcl, they will be able to issue commands easily to any Tcl-
based application. Second, Tcl provides programmability. All a Tcl application needs to do is to
implement a few application-specific low-level commands. Tcl provides many utility commands plus a
general programming interface for building up complex command procedures. By using Tcl, applications
need not re-implement these features.
Third, Tcl can be used as a common language for communicating between applications. Inter-application
communication is not built into the Tcl core described here, but various add-on libraries, such as the Tk
toolkit, allow applications to issue commands to each other. This makes it possible for applications to
work together in much more powerful ways than was previously possible.
Fourth, Jim Tcl includes a command processor, jimsh, which can be used to run standalone Tcl scripts,
or to run Tcl commands interactively.
For detailed information on the TCL language see:
http://jim.tcl.tk/fossil/doc/trunk/Tcl_shipped.html
75