Introduction to the Tcl Language
The next five chapters constitute a Tcl language tutorial. This chapter provides an overview of the Tcl syntax, data structures, and enough commands to develop applications. Chapter 4 discusses Tcl I/O support for files, pipes, and sockets. Chapters 5–8 introduce more commands and techniques and provide examples showing how Tcl data constructs can be used to create complex data constructs such as structures and trees. Chapters 9 and 10 introduce the TclOO object-oriented support package and explain some tricks in using dynamic and introspective object-oriented programming effectively.
This introduction to the Tcl language will give you an overview of how to use Tcl, rather than be a complete listing of all commands and all options. The on-line reference pages are the complete reference for the commands. See Chapter 1 for a discussion on how to access the on-line help on UNIX, Macintosh, and Windows platforms. The companion website contains a Tcl/Tk reference guide that contains brief listings of all commands and all options.
If you prefer a more extensive tutorial, see the tutorials list on the companion website. You will find a copy of TclTutor, a computer-assisted instruction program that covers all of the commands in Tcl, and most of the command options.
Chapters 11 through 14 constitute the Tk tutorial. If you are performing graphics programming, you may be tempted to skip ahead to those chapters and just read about the GUIs. Don’t do it! Tcl is the glue that holds the graphic widgets together. Tk and the other Tcl extensions build on the Tcl foundation. If you glance ahead for the Tk tutorial, plan on coming back to fill in the gaps.
This book will print the command syntax using the font conventions used by the Tcl on-line manual and help pages. This convention is as follows.
commandname – The command name appears first in this type font.
subcommandname – If the command supports subcommands, they will also be in this type font.
-option - Options appear in italics. The first character is a dash (-).
argument - Arguments to a command appear in italics.
?-option? – Options that are not required are bounded by question marks.
?argument? - Arguments that are not required are bounded by question marks.
The following is an example.
Syntax: puts ?-nonewline? ?channel? outputString
The command name is puts. The puts command will accept the options -nonewline and channel as arguments, and must include an outputString argument.