TCL, pronounced "tickle" or "tee see ell", is an interpreted language developed by John K. Ousterhout at the University of California - Berkley. TCL is currently supported by Sun Microsystems, Inc. It is public domain software and available on all platforms currently supported by NX.
TCL is the official NX language for "user-supplied" rules, such as the Event Handler used by Post.
TCL code is contained in a TCL script. The script can contain code inside of procs (TCL procedures) and code outside of procs. The code outside of procs, is executed at the time that the interpreter reads the script. The code contained inside the procs is only executed when the proc is called.
The TCL language allows use of both local and global variables. TCL provides numeric, string, logical, and relational operations. It is very strong at string processing. The TCL language provides control structures such as: if, while, for, foreach, break, continue, switch, eval, expr, and source.
It provides facilities for error handling, file I/O, process spawning and limited debugging capabilities. TCL allows you to easily build GUI interfaces by using Tk.
#!/usr/local/bin/tclsh
proc fact x {
if { $x <= 1 } { return 1 }
expr $x * [fact [expr $x - 1]]
}
# Main
if { $argc != 2 } {
puts "Usage: $argv0 <input file> <output file>"
exit 1
}
set infile [open [lindex argv 0] r]
set outfile [open [lindex argv 1] w]
while { [gets $infile number] >= 0 } {
set value [fact $number]
puts $outfile $value
}
close $infile
close $outfile
#Now remove the input file
exec rm [lindex argv 1]
When creating TCL scripts and procedures you can use any commands and functionality allowed by the "standard" TCL language. In addition, TCL is highly "extensible", meaning that you can add new commands to the interpreter very easily.
NX has added special procedures to allow you to further control the Manufacturing Output Managers output and to query the NX system for values for Expression Subsystem Variables.
These special procedures were developed using the same metalanguage that you will use to develop the Definition File. For more information regarding the metalanguage, please refer to Definition File Metalanguage.
These special procedures are listed in the Procedures Added To the Translator section.
<argument> indicates that the argument is mandatory.
<argument>+ indicates 1 or more arguments may be used.
{argument} indicates that the argument is optional.