Some features of Tcl
proc myproc {a b c} {
puts "The arguments to this program are $a $b $c"
return 5
}
console show
wm withdraw .
set result [myproc 1 2 3]
puts $result
Note that the `console show' and `wm withdraw .' are a couple of
housekeeping commands needed by the wish interpretator. Note that you
can type in commands into the wish console. This is a good way to
check out how different tcl commands work. A second option is to run programs from the command line. Here, you should use the tclsh interpretator (in which you cannot run tk commands, just tcl commands).For this option, you need to remove the `console show' and `wm withdraw .' Assuming your program is call hw1.tcl, you would enter the following from the command line `tclsh hw1.tcl'. Of course you might have to indicate the full pathname for tclsh.
There is also no built in debugging facility. Instead, you need to rely on puts statements, and perhaps after 1000 to slow down the rate of messages. Students in past years have used this option.
With TclPro, you can debug your program, but will need to use a separate program to edit it. Each time you change your program (in a separate text editor), you need to press the Refresh button in the File menu. There is a Guide to using TclPro that you get when you download. Note that TclPro works with Tcl8.3. There are more recent versions of Tcl available, so this is one drawback, but it will have little impact on you in this course.
if {$a == "quit"}
exit
You also need to be careful of comment lines, which start with a #.
In general, do not have a `{' or '}' brace in your comment.
Here is a site that has man pages of the Tcl commands (from Tcl 8.3): http://tcl.activestate.com/man/tcl8.3/TclCmd/contents.htm.
A good book about Tcl is: Tcl and the Tk toolkit by John Ousterhout, Addison-Wesley, ISBN 0-2010-63337-X.
A good online tutorial is http://xyresix.com/nwsbook/index.html?P=contents. You might want to start at the following search page though: http://xyresix.com/nwsbook/search.html. The author of this site has really great examples, and points out the most common mistakes.
After you download it, get a syntax file (to make all the keywords pretty colors) for it from the add-ons: http://www.textpad.com/add-ons/synn2t.html. One of my students uses the syntax file TCL/TK (4), but the TCL from 2003 is probably also good - only difference is really the keywords and that's pretty easy to tweak yourself.