Intro TCL
Intro TCL
George Whiteman
March 31, 2002
1
March 31, 2002 Introduction to Tcl/Tk
Contents
1 Introduction 6
4 Interpreter shells 9
4.1 The tclsh interpreter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.2 The wish interpreter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5 Manpage Support 11
6 Getting started 12
6.1 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.2 Line Continuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.3 Curly Braces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6.4 Square Brackets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6.5 Substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6.6 Math Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6.7 Octal Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
8 Flow Control 18
8.1 if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
9 Loop Control 19
9.1 for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
9.2 foreach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
9.3 while . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
12 Regular Expressions 29
12.1 regexp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Page 2
March 31, 2002 Introduction to Tcl/Tk
12.2 regsub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
13 Tk Geometry Management 30
13.1 pack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
13.2 grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
13.3 place . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
14 Tk Widgets 31
14.1 button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
14.2 label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
14.3 entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
14.4 text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
14.5 menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
14.6 canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Page 3
March 31, 2002 Introduction to Tcl/Tk
Revision History
Revision Date Comment
0.1 2002-03-13 Initial Draft - partial Tcl with limited examples
0.2 2002-03-29 Completed Tcl/Tk examples
Page 4
March 31, 2002 Introduction to Tcl/Tk
List of Examples
ex arg.tcl 22
ex array.tcl 17
ex button.tcl 32
ex canvas.tcl 37
ex catch.tcl 21
ex comment.tcl 12
ex entry.tcl 34
ex expr.tcl 13
ex fconfigure.tcl 28
ex file join.tcl 26
ex file read.tcl 27
ex file write.tcl 27
ex for.tcl 19
ex foreach.tcl 19
ex hostname.tcl 24
ex if problems.tcl 18
ex label.tcl 33
ex line continue.tcl 12
ex list.tcl 16
ex menu.tcl 36
ex os.tcl 23
ex proc.tcl 20
ex quoting.tcl 13
ex regexp.tcl 29
ex regexp in.tcl 29
ex regsub.tcl 30
ex source.tcl 21
ex source err.tcl 21
ex string.tcl 15
ex text.tcl 35
ex time.tcl 25
ex variable.tcl 14
ex while.tcl 19
Definitions
Page 5
March 31, 2002 Introduction to Tcl/Tk
1 Introduction
This white paper is intended to be an short introduction to the Tcl/Tk scripting language. An attempt was made to
include the most important Tcl concepts, pitfals, and frequently used programming constructs.
There are several excellent books listed in the bibliography at the end of this white paper. A few short examples
were taken verbatim from these books and were hopefully referenced accurately. This white paper is not a replace-
ment for these texts. If you are serious about learning the Tcl/Tk scripting language please go purchase the books.
This white paper is work in progress. Any corrections or suggestions can be set to:
whiteman@neo.rr.com
http://home.neo.rr.com/whiteman
The history of Tcl/Tk while not all that incredibly interesting when viewed on its own is a great example of how
the open source movement can and does work. Over the span of 20 years a simple modular concept has been devel-
oped and improved by academia, major corporations, startups, the open source community, and commercial software
developers. All the while the code has remained free and open sourced.
early 1980s
Tcl grows out of Dr. John Ousterhout work on IC design tools at the University of California at Berkeley. The name
Tcl (Tool Command Language) was derived from the intended usage as an embedded command processor.
1988
Ousterhout starts work on Tcl and sees complexity of GUIs growing, concludes that the large graphical systems should
be built out of reusable components. The Tk toolkit is born.
1989
Ousterhout gives a talk on Tcl during the Berkeley Industrial Liaison Conference. Gives away a few copies of Tcl to
early adopters.
1990
Ousterhout presented a paper on Tcl at the USENIX Conference. Decides to make the Tcl source code freely available
on the FTP site at Berkeley. After the USENIX presentation, Don Libes of the National Institute of Standards and
Technology, downloads Tcl and produces Expect. Expect becomes popular among system administrators.
Page 6
March 31, 2002 Introduction to Tcl/Tk
1991
The basic features of Tk became usable. Ousterhout presents a paper on Tk at both the USENIX Conference and the
X Conference.
1992
Tk is impoved with multi-line text widgets and a powerful canvas widget. Tk usage begins to increase dramatically.
1994
Ousterhout leaves Berkeley for Sun Microsystems. Concerns over Tcl becoming a proprietary language are discussed
on the comp.lang.tcl newsgroup. Sun puts a dozen people on the team.
Tcl/Tk gets ported cross-platform to Windows and the Macintosh by Scott Stanton and Ray Johnson. Brian Lewis
builds a bytecode compiler for Tcl scripts, which provids a speedup of 10x. Jacob Levy implements Safe-Tcl, a
powerful security model that allows untrusted scripts to be evaluated safely. Jacob Levy and Laurent Demailly build
a Tcl plugin, so that Tcl scripts can be evaluated in a Web browser.
1995
Sun FTP site dowloads hit 2000 per week.
1997
Ousterhout and Sarah Daniels leave Sun to form Scriptics (Ajuba). Within a month about half of the Sun Tcl team
joined Scriptics and begins development of TclPro development tools.
1998
The Tcl Pro 1.0 development tools ship.
1999
Tcl/Tk 8.1 first major open source release. This release supports Unicode, thread safety, and Unicode regular expres-
sions. Tcl now has all the facilities needed for mission-critical enterprise applications.
2000
Tcl/Tk moved to SourceForge. TclPro is open sourced.
2001
ActiveState improves the open source Tcl core releases ActiveTcl as a complement to their ActivePerl offering. Adds
support in new Komodo IDE along with Perl and Python.
Today
Tcl/Tk downloaded at a rate of +30,000/month. Windows 55%, Unix 40%.
Glue - Tcl can exec other programs, catch output, control sockets, communicate with the OS. Tk has suport for
buttons, labels, scrollbars, icons, menuing, text windows and a graphical canvas. Applications can communicate with
a Web browser.
Cross Platform Development - Tcl/Tk has been ported to most popular operating systems. The source code is
portable and can be interpreted on Linux, Windows, Solaris, Mac as well as other platforms, with little or no modifi-
Page 7
March 31, 2002 Introduction to Tcl/Tk
cation.
Rapid Prototyping - Depending upon the project’s complexity, the application or a prototype of the application, can
be functioning within a in a matter of days. Changes can be made within a matter of hours. This will impress your
customers, make your manager happy, and hopefully have more personal time.
Configuration Files - Many custom tasks may require configuration files. Tcl supports this by sourcing Tcl code to
setup variables. There is no need to generate a specification and a parser for the configuration file.
Cost - The software is free. Prototyping and development time is minimized. Tcl/Tk may satisfy the requirements of
many production applications.
Open Source Code - Open source allows developers to embed the language into a software product. Many EDA
vendors are shipping cross platform applications with Tcl and the interactive command and scripted interface.
Embedded Design - Tcl/Tk was designed to be embedded and modular from the start.
Consistancy - Embedded products have a standard language interface. The Tcl/Tk code has several formatting rules.
Commercial Tool Support - Commercial Debuggers, Compilers and IDE are available.
Speed - Execution speed may be an issue. Tcl/Tk is an interpreted language by default, however compilers are
available.
Scripted Execution - Since Tcl/Tk is a scripted language the source is visable by default.
String Handling - Although Tcl/Tk has a rich set of string and regular expression functions it is probably not the
best choice for string handling.
Language - Tcl/Tk is a somewhat verbose language and window management becomes more cumbersome as project
complexity grows. This lead to the development of the object oriented language [incr Tcl].
Alienation - Saying ”tickle” may result in the comment ”me Elmo” in front others. Feel free to refer to the language
as Tee-See-Ell if this happens.
Page 8
March 31, 2002 Introduction to Tcl/Tk
4 Interpreter shells
tclsh is the Tcl shell interpreter. This interpreter does not include support for graphical Tk applications. It is executed
by entering
tclsh
tclsh program_name.tcl
at the command prompt. Under Windows this program is named tclsh.exe or may contain a version number such as
tclsh83.exe. Scripts can also be executed by entering
source program_name.tcl
Screenshot of tclsh
Page 9
March 31, 2002 Introduction to Tcl/Tk
wish is the Tcl/Tk interpreter. It supports Tcl commands as well as the graphical tool kit (Tk). It is executed by
entering
wish
at the command prompt. Under Windows there is a program named wish.exe or may also contain a version name such
as wish83.exe. Scripts can also be executed by entering
wish program_name.tcl
Under Unix, Tcl applications can also be executed by entering in the filename at the command prompt. For this to
work the Tcl filename must be referenced with an absolute path or be found in the current search path. The Tcl file
must have execute privileges. The first line of the file should be:
#!/usr/bin/tclsh
#!/usr/bin/wish
Page 10
March 31, 2002 Introduction to Tcl/Tk
5 Manpage Support
The manpage (man) command is supported by the tclsh interpreter. Be aware that command not built into the tclsh
interpreter will be passed to the operating system for execution, so system manpages may be displayed. A truncated
example man page follows:
$ tclsh
% man fconfigure
_________________________________________________________________
NAME
fconfigure - Set and get options on a channel
SYNOPSIS
fconfigure channelId
fconfigure channelId name
fconfigure channelId name value ?name value ...?
_________________________________________________________________
DESCRIPTION
The fconfigure command sets and retrieves options for
channels. ChannelId identifies the channel for which to
set or query an option. If no name or value arguments are
supplied, the command returns a list containing alternat
ing option names and values for the channel. If name is
supplied but no value then the command returns the current
value of the given option. If one or more pairs of name
and value are supplied, the command sets each of the named
options to the corresponding value; in this case the
return value is an empty string.
It should also be noted that this automatic passing of non Tcl commands to the operating system can be disabled by
setting the auto noexec variable.
Page 11
March 31, 2002 Introduction to Tcl/Tk
6 Getting started
6.1 Comments
Comments are line based in Tcl. End of line comments are allowed but a semicolon MUST be placed at the end of
the interpreted code on that line.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_comment.tcl
0004 #-----------------------------------------------------------
0005 # tcl is line comment based
0006 # no need to use semicolons for line terminations
0007 # but they are allowed
0008
0009 set real_years 4 # this is a malformed comment (no semicolon)
0010
0011 set dog_name "spot"; # semicolon is require for EOL commment
0012
0013 set dog_years [expr (7 * $real_years)]
0014
0015 puts "my dog $dog_name is $real_years"
0016 puts "he acts $dog_years old"
Line continuation is accomplished by using a backslash. Do not follow the backslash with any characters, or even any
whitespace characters! The backslash escapes the next character which is intended to be the newline.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_line_continue.tcl
0004 #-----------------------------------------------------------
0005 # the backslash escapes the new line
0006 # dont put a space after it!
0007
0008 set members { \
0009 george \
0010 fred \
0011 jeff \
0012 alice \
0013 }
0014
0015 puts $members
Page 12
March 31, 2002 Introduction to Tcl/Tk
Curly braces around a string do not allow variable substitution within the string, the string is taken literally.
Unmatched curly braces may cause the interpreter to wait indefinitely for more input, no errors, no warnings, no
output.
Curly braces count even if they are in a comment, this will cause brace mismatches that can be difficult to find.
6.5 Substitution
Double quotes will allow substitution in the string being quoted. Curly braces will not allow substitution.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_quoting.tcl
0004 #-----------------------------------------------------------
0005 set years 41
0006 set years_sub "I am $years";
0007 set years_no_sub {I am $years};
0008
0009 puts "this string got substituted - weak quoting"
0010 puts $years_sub
0011
0012 puts "this string did not substitute - rigid quoting"
0013 puts $years_no_sub
The interpreter is told to perform math functions by using the expr command.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_expr.tcl
0004 #-----------------------------------------------------------
0005 set r 2.0
0006 set pi [expr { 4 * atan(1.0) }]
0007 set area [expr {$pi * $r * $r}]
0008
0009 puts "r: $r"
0010 puts "pi: $pi"
0011 puts "area: $area"
Page 13
March 31, 2002 Introduction to Tcl/Tk
Numbers with a leading zero, like 0644, are interpreted as octal. This is typically encountered when setting permission
modes during the opening a file for writing. The leading zero may cause problems with the Tcl interpreter, when doing
comparisons or assigments on numbers representing time of day. A digit that is greater than or equal to 8 preceeded
by a leading zero digit will cause an illegal octal number error.
Variables are initialized with the set command. Variable are typeless strings but it is important how they are initialized.
Initialization with an integer (no decimal) or a real value (decimal) will produce different results. Variables with
leading zeros are assumed to be in an octal format.
Variables are set without a dollar sign preceeding the variable name. Variables are referenced with a dollar sign
preceeding the variable name. This is in contrast to other scripting languages like Perl that uses dollar signs for both
initialization and referencing.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_variable.tcl
0004 #-----------------------------------------------------------
0005 set four 4
0006 set four_real 4.0
0007 set three 3
0008
0009 set threefourths [expr $three / $four]
0010 puts "threefourths: $threefourths"
0011
0012 set threefourths_real [expr $three / $four_real]
0013 puts "threefourths_real: $threefourths_real"
Global variables are declared in procedures, not up front. Non-global variables within a procedure are local to the
procedure.
The info command can be used to determine if a variable exists or not.
Page 14
March 31, 2002 Introduction to Tcl/Tk
7.2 Strings
There is a rich set of string processing commands in Tcl. The table below is not an exhaustive list but it does contain
the most commonly used string commands.
Command Description
string bytelength str returns number of bytes used in for string storage
string compare str1 str2 compares string and returns -1, 0 or 1
string equal str1 str2 test equality of string and returns 1 if equal
string first str1 str2 returns the index of the first occurrence of str2 in str1, else returns -1
string last str1 str2 returns the index of the last occurrence of str2 in str1, else returns -1
string length str returns the length of str
string match pattern str returns 1 if str matches pattern
string range str start end returns substring of str from start to end
string repeat str n returns a str repeated n times
string tolower str returns a lowercased str
string totitle str returns str with the first letter capitalized
string toupper str returns a uppercased str
string trim str trims whitespace from str
string trimleft str trims whitespace from the end of str
string trimright str trims whitespace from the beginning of str
Many of these string commands have additional options such as nocase, positions, or non-default characters. See the
respective manpages a more detailed description.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_string.tcl
0004 #-----------------------------------------------------------
0005 set str1 "th"
0006 set str2 "Is this supposed to be a good thing, Miri?"
0007
0008 puts "length: [string bytelength $str2]"
0009 puts "first: [string first $str1 $str2]"
0010 puts "last: [string last $str1 $str2]"
0011 puts "toupper: [string toupper $str2]"
Page 15
March 31, 2002 Introduction to Tcl/Tk
7.3 Lists
Lists are a sequence of values separated by whitespace. Braces are typically used to group items together into a single
value in a list. Lists are not used to build complex data structures. Tcl lists are strings with a corresponding set of data
manipulation commands. A incomplete summary of these commands are listed below.
Command Description
list arg1 arg2 ... constructs a list out of several arguments
lindex list n returns the indexed element from the list
llength list returns the number of elements in a list
lrange list n m returns the range of elements of a list
lappend list arg1 arg2 ... appends elements to a list
linsert list index arg1 arg2 ... inserts elements to a list and returns a new list
lreplace list n m arg1 arg2 ... replaces elements n thru m with args and returns a new list
lsearch list value return index of value in list, else -1
lsort list returns a sorted list
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_list.tcl
0004 #-----------------------------------------------------------
0005 set the_list { {Red Hat} SuSE Mandrake Debian }
0006 puts "value 0: [lindex $the_list 0]"
0007 puts "value 1: [lindex $the_list 1]"
0008 puts "value 2: [lindex $the_list 2]"
0009 puts "value 3: [lindex $the_list 3]"
0010
0011 set the_sorted_list [lsort $the_list]
0012 puts "value 0: [lindex $the_sorted_list 0]"
0013 puts "value 1: [lindex $the_sorted_list 1]"
0014 puts "value 2: [lindex $the_sorted_list 2]"
0015 puts "value 3: [lindex $the_sorted_list 3]"
Page 16
March 31, 2002 Introduction to Tcl/Tk
7.4 Arrays
Arrays in Tcl are associative, meaning that they are stored using a hash table. The array index to the associative array
is placed within parenthesis. If the index is numeric the array syntax appears similar to other languages that do not
use associative arrays. However, the indexes need not be numeric.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_array.tcl
0004 #-----------------------------------------------------------
0005 proc P_add_contact { key last_name email phone } {
0006 global contact_last_name
0007 global contact_email
0008 global contact_phone
0009
0010 set contact_last_name($key) $last_name
0011 set contact_email($key) $email
0012 set contact_phone($key) $phone
0013
0014 puts "key: $key"
0015 puts "name: $contact_last_name($key)"
0016 puts "email: $contact_email($key)"
0017 puts "phone: $contact_phone($key)"
0018
0019 return
0020 }
0021
0022 P_add_contact 1000 whiteman whiteman@neo.rr.com 555-555-5555
0023 P_add_contact 1001 stimpy stimpy@stimpy.com 555-555-5556
0024 P_add_contact alphakey ren ren@ren.com 555-555-5557
Page 17
March 31, 2002 Introduction to Tcl/Tk
8 Flow Control
8.1 if
Tcl is quite picky about the format of the if conditional statement. This is related to how the parser works. An example
has been included to better illustrate the formatting of this conditional statement.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_if_problems.tcl
0004 #-----------------------------------------------------------
0005 set a 1
0006
0007 # the if statement commented out causes a curly bracket mismatch
0008 # if {$a == 1} {
0009 if {$a == 0} {
0010 puts "a is zero"
0011 } else {
0012 puts "a is not zero"
0013 }
0014
0015 # need space between curly brackets
0016 if {$a == 0}{
0017 puts "a is zero"
0018 } else {
0019 puts "a is not zero"
0020 }
0021
0022 # else is misplaced
0023 if {$a == 0} {
0024 puts "a is zero"
0025 }
0026 else {
0027 puts "a is not zero"
0028 }
0029
0030 # formatted properly
0031 if {$a == 0} {
0032 puts "a is zero"
0033 } else {
0034 puts "a is not zero"
0035 }
0036
0037 # this is also formatted properly
0038 if {$a == 0} {
0039 puts "a is zero"
0040 } else {
0041 puts "a is not zero"
0042 }
Page 18
March 31, 2002 Introduction to Tcl/Tk
9 Loop Control
The syntax for loop control is covered in the next three examples.
9.1 for
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_for.tcl
0004 #-----------------------------------------------------------
0005 for { set loopcnt 0 } { $loopcnt < 10 } { incr loopcnt } {
0006 puts "loopcnt: $loopcnt"
0007 }
9.2 foreach
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_foreach.tcl
0004 #-----------------------------------------------------------
0005 set member_list {
0006 george 41
0007 alice 37
0008 fred 30
0009 sally 34
0010 dustin 23
0011 }
0012
0013 foreach {name age} $member_list {
0014 puts [format "name: %-20s age: %3d" $name $age]
0015 }
9.3 while
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_while.tcl
0004 #-----------------------------------------------------------
0005 set random_int 0
0006
0007 while { 1 } {
0008 # loop exit condition
0009 if { $random_int == 1 } {
0010 break
0011 }
0012 # loop processing
0013 set random_float [expr (10 * rand())]
0014 set random_int [expr (int($random_float))]
0015 puts $random_int
0016 }
Page 19
March 31, 2002 Introduction to Tcl/Tk
Procedures must be declared before they are referenced. In a script containing many procedures main program execu-
tion may be located at the bottom of the file.
Procedures may contain optional pass variables and may also specify defaults for these variables.
Procedure names may overwrite built in commands. By defining an exit procedure the normal built in exit command
will be modified. This is not recommended practice and some developers use naming conventions to avoid problems.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_proc.tcl
0004 #-----------------------------------------------------------
0005 #-----------------------------------------------------------
0006 # procedure 1
0007 #-----------------------------------------------------------
0008 proc P_procedure1 { } {
0009 global variable1
0010 global variable2
0011
0012 puts "variable1: $variable1"
0013 puts "variable2: $variable2"
0014
0015 set variable3 [expr ($variable1 + $variable2) ]
0016
0017 return $variable3
0018 }
0019
0020 #-----------------------------------------------------------
0021 # procedure 2
0022 #-----------------------------------------------------------
0023 proc P_procedure2 { variable3 } {
0024 global variable1
0025 global variable2
0026
0027 puts "variable3: $variable3"
0028
0029 return
0030 }
0031
0032 #-----------------------------------------------------------
0033 # call the procedures
0034 #-----------------------------------------------------------
0035 set variable1 1.0
0036 set variable2 2.0
0037
0038 set temp [P_procedure1]
0039
0040 P_procedure2 $temp
Page 20
March 31, 2002 Introduction to Tcl/Tk
Scripts can be subdivided into seperate sections by use of the source statement. This provides similar functionality to
the ”require” in Perl or ”include” in the C language. Sourcing other Tcl scripts from a main Tcl script provides a way
to separate shared procedures, configuration data, environment data, and system dependent data.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_source.tcl
0004 #-----------------------------------------------------------
0005 source ex_source_err.tcl
0006
0007 P_msg_info "We can Tcl code common to several modules"
0008 P_msg_warn "This is a warning message"
0009 P_msg_err "This is an error message"
Below is a listing of the Tcl code that was contained in a different file and sourced.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_source_err.tcl
0004 #-----------------------------------------------------------
0005 proc P_msg_info { msg } {
0006 puts "INFO: $msg"
0007 }
0008
0009 proc P_msg_warn { msg } {
0010 puts "WARN: $msg"
0011 }
0012
0013 proc P_msg_err { msg } {
0014 puts "ERR: $msg"
0015 }
System calls are performed by the exec command. The following example shows the exec command used with the
catch command. This is useful for running a system command and capturing the output from that command. These
procedures determine the operating system and hostname of the machine running the script. The return values of these
procedures can be used to make system and hostname dependent decisions allowing the same code to run on different
platforms and hosts.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_catch.tcl
0004 #-----------------------------------------------------------
0005 set system_cmd "ls"
0006 set system_arg "-la"
0007 catch { exec $system_cmd $system_arg } ls_data
0008 puts $ls_data
Page 21
March 31, 2002 Introduction to Tcl/Tk
As with many other languages Tcl can be passed arguments from the command line at the start of command execution.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_arg.tcl
0004 #-----------------------------------------------------------
0005 proc P_ex_arg { v0 v1 v2 } {
0006 puts "v0: $v0"
0007 puts "v1: $v1"
0008 puts "v2: $v2"
0009 return
0010 }
0011
0012 # check for the proper number of command line arguments
0013 if { $argc == 3 } {
0014 # print out the script name
0015 puts "executing $argv0..."
0016 # setup the command line arguments
0017 set arg1 [lindex $argv 0]
0018 set arg2 [lindex $argv 1]
0019 set arg3 [lindex $argv 2]
0020 # call the main routine
0021 P_ex_arg $arg1 $arg2 $arg3
0022 exit 0
0023 } else {
0024 # put out an error message
0025 puts "usage is: ex_arg.tcl arg1 arg2 arg3"
0026 # set exit status
0027 exit 1
0028 }
Page 22
March 31, 2002 Introduction to Tcl/Tk
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_os.tcl
0004 #-----------------------------------------------------------
0005 #-----------------------------------------------------------
0006 # determines operating system
0007 #-----------------------------------------------------------
0008 proc P_determine_os { } {
0009
0010 # set the subroutine name
0011 set sub_name {P_determine_os}
0012
0013 # give the user some information
0014 puts "($sub_name) INFO: determining operating system"
0015
0016 # execute the system command and catch the output
0017 catch { exec uname -sr } uname_return_data
0018
0019 # tell the user what uname returned
0020 puts "($sub_name) INFO: uname -sr returned: $uname_return_data"
0021
0022 # format the output of uname
0023 if { [string first "Linux" $uname_return_data] == 0 } {
0024 set os_type linux
0025 } elseif { [string first "CYGWIN_NT" $uname_return_data] == 0 } {
0026 set os_type cygwin
0027 } elseif { [string first "SunOS" $uname_return_data] == 0 } {
0028 set os_type solaris
0029 } else {
0030 set os_type undefined
0031 }
0032
0033 puts "($sub_name) INFO: os_type set to: $os_type"
0034
0035 return $os_type
0036 }
0037
0038 #-----------------------------------------------------------
0039 # determine operating system using a system call
0040 #-----------------------------------------------------------
0041 P_determine_os
0042 exit
Page 23
March 31, 2002 Introduction to Tcl/Tk
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_hostname.tcl
0004 #-----------------------------------------------------------
0005 #-----------------------------------------------------------
0006 # determines hostname
0007 #-----------------------------------------------------------
0008 proc P_determine_hostname { } {
0009
0010 # set the subroutine name
0011 set sub_name {P_determine_hostname}
0012
0013 # give the user some information
0014 puts "($sub_name) INFO: determining hostname"
0015
0016 # do the system call
0017 catch { exec hostname } hostname_return_data
0018
0019 # tell the user what uname returned
0020 puts "($sub_name) INFO: hostname returned: $hostname_return_data"
0021
0022 # no translation
0023 set hostname $hostname_return_data
0024
0025 # trim the hostname
0026 set hostname [string trim $hostname]
0027
0028 # lowercase the hostname
0029 set hostname [string tolower $hostname]
0030
0031 puts "($sub_name) INFO: hostname set to: $hostname"
0032
0033 return $hostname
0034 }
0035
0036 #-----------------------------------------------------------
0037 # determine the hostname using a system call
0038 #-----------------------------------------------------------
0039 P_determine_hostname
0040 exit
Page 24
March 31, 2002 Introduction to Tcl/Tk
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_time.tcl
0004 #-----------------------------------------------------------
0005 #-----------------------------------------------------------
0006 # sets the current_date and current_time global variables
0007 #-----------------------------------------------------------
0008 proc P_set_time { } {
0009 global current_date
0010 global current_time
0011
0012 # set the subroutine name
0013 set sub_name {P_set_time}
0014
0015 # format time as YYYYMMDD
0016 set current_date [clock format [clock seconds] -format "%Y%m%d"]
0017
0018 # format the time as HHMM
0019 set current_time [clock format [clock seconds] -format "%H%M"]
0020
0021 # give the user some information
0022 puts "($sub_name) INFO: current date: $current_date"
0023 puts "($sub_name) INFO: current time: $current_time"
0024
0025 return
0026 }
0027
0028 #-----------------------------------------------------------
0029 # call the P_set_time procedure
0030 #-----------------------------------------------------------
0031 P_set_time
0032 exit
Page 25
March 31, 2002 Introduction to Tcl/Tk
One of the benefits of Tcl and Tk is its ability to execute cross platform. File pathnames (slash, backslash, colon) and
file formats (cr-lf combinations) have always been problematic to programmers. Tcl solves this problem by building
up pathnames using the file join command.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_file_join.tcl
0004 #-----------------------------------------------------------
0005 #-----------------------------------------------------------
0006 # produces a text file
0007 #-----------------------------------------------------------
0008 proc P_create_file { } {
0009
0010 # set the subroutine name
0011 set sub_name "P_create_file"
0012
0013 # build up the file name
0014 set abs_file_name [file join "/home" "gwhitema"]
0015 set abs_file_name [file join $abs_file_name "tcl"]
0016 set abs_file_name [file join $abs_file_name "training"]
0017 set abs_file_name [file join $abs_file_name "ex_file_join.txt"]
0018
0019 # tell the user what is happening
0020 puts "($sub_name) INFO: creating file: $abs_file_name"
0021
0022 # open the html file
0023 set file_id [open $abs_file_name w 0644]
0024
0025 # write some text to the file
0026 puts $file_id "this is some text"
0027
0028 # close the file
0029 close $file_id
0030
0031 return
0032 }
0033
0034 #-----------------------------------------------------------
0035 # call the P_create_file
0036 #-----------------------------------------------------------
0037 P_create_file
0038 exit
Page 26
March 31, 2002 Introduction to Tcl/Tk
Reading data from a file line by line is a common task in programming. The following example details how to open a
file for reading and split the data in the file on the new line.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_file_read.tcl
0004 #-----------------------------------------------------------
0005 proc P_read_file { file_name } {
0006
0007 # open the file
0008 set file_id [open $file_name r]
0009
0010 # read in the file line by line
0011 foreach line [split [read $file_id] \n] {
0012 # process the line
0013 puts $line
0014 }
0015 # close the file
0016 close $file_id
0017
0018 return
0019 }
0020
0021 #-----------------------------------------------------------
0022 # example: example_file_read.tcl
0023 #-----------------------------------------------------------
0024 P_read_file "ex_file_read.txt"
0025 exit
Writing data to a file is also a common programming task. The following examples details how to open a file for
writing. Notice the leading zero in the octal file permission data field when the file is initially opened.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_file_write.tcl
0004 #-----------------------------------------------------------
0005 set file_name "ex_file_write.txt"
0006
0007 # open the dst file for write
0008 set file_id [ open $file_name w 0644 ]
0009
0010 # put some data in the file
0011 for { set loopcnt 0 } { $loopcnt < 10 } { incr loopcnt } {
0012 puts $file_id "loopcnt: $loopcnt"
0013 }
0014
0015 # close the file
0016 close $file_id
Page 27
March 31, 2002 Introduction to Tcl/Tk
11.4 fconfigure
Tcl can also produce file formats targetted for one OS while executing on a different OS. This is accomplished by
usign the fconfigure command.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_fconfigure.tcl
0004 #-----------------------------------------------------------
0005 #-----------------------------------------------------------
0006 # produces a text file
0007 #-----------------------------------------------------------
0008 proc P_create_file_fconfigure { } {
0009
0010 # set the subroutine name
0011 set sub_name "P_create_file_fconfigure"
0012
0013 # build up the file name
0014 set abs_file_name [file join "/home" "gwhitema"]
0015 set abs_file_name [file join $abs_file_name "tcl"]
0016 set abs_file_name [file join $abs_file_name "training"]
0017 set abs_file_name [file join $abs_file_name "ex_fconfigure.txt"]
0018
0019 # tell the user what is happening
0020 puts "($sub_name) INFO: creating file: $abs_file_name"
0021
0022 # open the file
0023 set file_id [open $abs_file_name w 0644]
0024
0025 # generate using unix line terminations
0026 # fconfigure $file_id -translation lf
0027
0028 # generate using dos line terminations
0029 fconfigure $file_id -translation crlf
0030
0031 # generate using mac line terminations
0032 # fconfigure $file_id -translation cr
0033
0034 # write some text to the file
0035 puts $file_id "this is line 1"
0036 puts $file_id "this is line 2"
0037 puts $file_id "this is line 3"
0038
0039 # close the file
0040 close $file_id
0041
0042 return
0043 }
0044
0045 #-----------------------------------------------------------
0046 # call the P_create_file_fconfigure procedure
0047 #-----------------------------------------------------------
0048 P_create_file_fconfigure
0049 exit
Page 28
March 31, 2002 Introduction to Tcl/Tk
12 Regular Expressions
12.1 regexp
Regular expressions are supported through the use of the regexp statement. The following example reads in a file and
strips comments indicated by a # sign in the first column.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_regexp.tcl
0004 #-----------------------------------------------------------
0005 # setup the filename
0006 set file_name ex_regexp_in.txt
0007
0008 # open the file for reading
0009 set file_id [open $file_name r]
0010
0011 # read in the file line by line
0012 foreach line [split [read $file_id] \n] {
0013 # process the line
0014 if { [regexp "(ˆ#)" $line match] == 0 } {
0015 puts $line
0016 }
0017 }
0018
0019 # close the file
0020 close $file_id
0001 #-----------------------------------------------------------
0002 # example: ex_regexp_in.txt
0003 #-----------------------------------------------------------
0004 # this is comment 1
0005 cmd1
0006 # this is comment 2
0007 cmd2 arg1 arg2
0008 # this is comment 3
0009 cmd3 arg1 arg2 arg3
0010 # this is comment 4
0011 cmd4
0012 # this is comment 5
0013 cmd5
Page 29
March 31, 2002 Introduction to Tcl/Tk
12.2 regsub
String subsititutions are supported through the use of the regsub statement.
0001 #!/usr/bin/tclsh
0002 #-----------------------------------------------------------
0003 # example: ex_regsub.tcl
0004 #-----------------------------------------------------------
0005 # set up the src filename
0006 set src_file_name "input.txt"
0007 # set up the dst filename
0008 set dst_file_name "output.txt"
0009
0010 # open the src file for read
0011 set src_file_id [ open $src_file_name ]
0012 # open the dst file for write
0013 set dst_file_id [ open $dst_file_name w ]
0014
0015 # read the src line by line
0016 while {[gets $src_file_id line] >= 0} {
0017
0018 # put your from-to translation strings here
0019 puts $dst_file_id [regsub -all {cool} $line {dorky} line]
0020 }
0021
0022 # close both files
0023 close $src_file_id
0024 close $dst_file_id
13 Tk Geometry Management
Tk controls the construction of widgets using one or more geometry managers. Geometry managers control the
resizing and location of widgets during script execution. Various combinations of geometry managers can be used
within a single Tcl/Tk script.
13.1 pack
The pack geometry manager is the most commonly used. It operates by packing widgets within hierarchical frames.
13.2 grid
The grid geometry management allows for placement on a xy grid consisting of rows and columns. Although this
geometry management has limitations during resizing it is most commonly used with text or canvas widgets combined
with x and y scrollbars.
13.3 place
The place geometry manager allows for exact control over the placement of widgets.
Page 30
March 31, 2002 Introduction to Tcl/Tk
14 Tk Widgets
The following table lists the basic types of widgets used by Tk. This is not a complete table nor does it contain the
file dialog widgets available for use.
Widget Description
button creates a button to execute a command
radiobutton creates a set of buttons, 1 of n can be selected
checkbutton creates a set of buttons, any number can be selected
entry used for a single text input line
message creates a message text window
label typically used for labelling other widgets with read only text
scale slider control that calls a routine when the slider position changes
menubutton displays a scrolldown menu
menu holds menu pulldown items
listbox creates a list box that can be scrolled
scrollbar creates a scrollbar that is used to control other widgets
frame creates a frame to control the grouping of other widgets
toplevel creates a top level window with controls from the window manager
text creates a text window that can be edited
canvas creates a graphic window that is used for drawing and image display
Page 31
March 31, 2002 Introduction to Tcl/Tk
14.1 button
0001 #!/usr/bin/wish
0002 #-----------------------------------------------------------
0003 # example: ex_button.tcl
0004 #-----------------------------------------------------------
0005 # button command processor
0006 proc P_process_button { button_cmd_string } {
0007 puts $button_cmd_string
0008 return
0009 }
0010
0011 # set the font size (pts)
0012 set font_size 24
0013
0014 # frames for columns
0015 frame .c0
0016 frame .c1
0017 frame .c2
0018
0019 # button for upper case characters
0020 button .c0.b0 -text "B0" \
0021 -font "-family arial -weight bold -size $font_size" \
0022 -background #8080e0 -command { P_process_button "button 0" }
0023 button .c0.b1 -text "B1" \
0024 -font "-family arial -weight bold -size $font_size" \
0025 -background #8080e0 -command { P_process_button "button 1" }
0026 button .c1.b0 -text "B2" \
0027 -font "-family arial -weight bold -size $font_size" \
0028 -background #8080e0 -command { P_process_button "button 2" }
0029 button .c1.b1 -text "B3" \
0030 -font "-family arial -weight bold -size $font_size" \
0031 -background #8080e0 -command { P_process_button "button 3" }
0032 button .c2.b0 -text "B4" \
0033 -font "-family arial -weight bold -size $font_size" \
0034 -background #8080e0 -command { P_process_button "button 5" }
0035 button .c2.b1 -text "exit" \
0036 -font "-family arial -weight bold -size $font_size" \
0037 -background #ff0000 -command { exit }
0038
0039 # pack the buttons
0040 pack .c0.b0 -side top -fill both -expand true
0041 pack .c0.b1 -side top -fill both -expand true
0042 pack .c1.b0 -side top -fill both -expand true
0043 pack .c1.b1 -side top -fill both -expand true
0044 pack .c2.b0 -side top -fill both -expand true
0045 pack .c2.b1 -side top -fill both -expand true
0046
0047 # pack the column frames
0048 pack .c0 -side left -fill both -expand true
0049 pack .c1 -side left -fill both -expand true
0050 pack .c2 -side left -fill both -expand true
Page 32
March 31, 2002 Introduction to Tcl/Tk
14.2 label
0001 #!/usr/bin/wish
0002 #-----------------------------------------------------------
0003 # example: ex_label.tcl
0004 #-----------------------------------------------------------
0005 proc P_process_button { } {
0006 global current_string
0007 global display_width
0008
0009 if { [string compare $current_string "OFF"] == 0 } {
0010 set current_string "ON"
0011 } else {
0012 set current_string "OFF"
0013 }
0014
0015 .c0.l0 configure -text $current_string -width $display_width
0016
0017 return
0018 }
0019
0020 # display adjustments
0021 tk scaling 1
0022 set font_size 24
0023 set display_width 10
0024 set xpadding 10
0025 set ypadding 10
0026
0027 # setup the current label string
0028 set current_string "OFF"
0029
0030 # frame for column 0
0031 frame .c0
0032
0033 # button
0034 button .c0.b0 -text "toggle" \
0035 -font "-family arial -weight bold -size $font_size" \
0036 -background #808080 -command P_process_button
0037
0038 # label widget
0039 label .c0.l0 -text $current_string \
0040 -font "-family arial -weight bold -size $font_size" \
0041 -width $display_width
0042
0043 # pack the label, button, and column
0044 pack .c0.l0 -side top -fill both \
0045 -expand true -padx $xpadding -pady $ypadding
0046 pack .c0.b0 -side top -fill both
0047 pack .c0
Page 33
March 31, 2002 Introduction to Tcl/Tk
14.3 entry
0001 #!/usr/bin/wish
0002 #-----------------------------------------------------------
0003 # example: ex_entry.tcl
0004 #-----------------------------------------------------------
0005 proc P_contact_entry { } {
0006
0007 frame .contact_frame -borderwidth 2 -relief raised
0008
0009 label .contact_frame.last_name_label -text "last name"
0010 entry .contact_frame.last_name_entry -textvariable last_name -width 40
0011
0012 label .contact_frame.phone_label -text "phone"
0013 entry .contact_frame.phone_entry -textvariable phone -width 20
0014
0015 label .contact_frame.email_label -text "email"
0016 entry .contact_frame.email_entry -textvariable email -width 40
0017
0018 button .contact_frame.save_button -text "save" \
0019 -command { P_save_contact $last_name $phone $email }
0020
0021 button .contact_frame.exit_button -text "exit" \
0022 -command { exit }
0023
0024 pack .contact_frame.last_name_label -side top -fill x -expand true
0025 pack .contact_frame.last_name_entry -side top -fill x -expand true
0026 pack .contact_frame.phone_label -side top -fill x -expand true
0027 pack .contact_frame.phone_entry -side top -fill x -expand true
0028 pack .contact_frame.email_label -side top -fill x -expand true
0029 pack .contact_frame.email_entry -side top -fill x -expand true
0030 pack .contact_frame.save_button
0031 pack .contact_frame.exit_button
0032 pack .contact_frame -fill both -expand true
0033
0034 return
0035 }
0036
0037 proc P_save_contact { last_name phone email } {
0038 puts "<contact>"
0039 puts " <last_name>$last_name</last_name>"
0040 puts " <phone>$phone</phone>"
0041 puts " <email>$email</email>"
0042 puts "</contact>"
0043 return;
0044 }
0045
0046 P_contact_entry
Page 34
March 31, 2002 Introduction to Tcl/Tk
14.4 text
0001 #!/usr/bin/wish
0002 #-----------------------------------------------------------
0003 # example: ex_text.tcl
0004 #-----------------------------------------------------------
0005 # title on main window
0006 wm title . "Text Widget Example"
0007
0008 # text widget with y scroll bar
0009 text .txtwin -width 80 -height 20 -bg grey \
0010 -yscrollcommand ".yscroll set"
0011
0012 # scrollbar widget
0013 scrollbar .yscroll -command ".txtwin yview"
0014
0015 # pack the text window
0016 pack .txtwin -side left -fill y
0017
0018 # pack the scrollbar
0019 pack .yscroll -side right -fill y
Page 35
March 31, 2002 Introduction to Tcl/Tk
14.5 menu
0001 #!/usr/bin/wish
0002 #-----------------------------------------------------------
0003 # example: ex_menu.tcl
0004 #-----------------------------------------------------------
0005 proc P_menu { } {
0006 global editor
0007
0008 frame .mbar -borderwidth 2 -relief raised
0009 frame .msg -borderwidth 2 -relief raised
0010
0011 menubutton .mbar.file -text "file" -menu .mbar.file.menupull
0012
0013 menu .mbar.file.menupull
0014 .mbar.file.menupull add command \
0015 -label "Edit" -command { exec $editor }
0016 .mbar.file.menupull add command \
0017 -label "Exit" -command { exit }
0018
0019 text .msg.txtwin -width 80 -height 20 -bg grey \
0020 -yscrollcommand ".msg.yscroll set"
0021
0022 # scrollbar widget
0023 scrollbar .msg.yscroll -command ".msg.txtwin yview"
0024
0025 pack .mbar.file -side left
0026 pack .msg.txtwin -side left -expand true -fill both
0027 pack .msg.yscroll -side left -fill y
0028
0029 pack .mbar -side top -fill x
0030 pack .msg -side top -fill both -expand true
0031
0032 return
0033 }
0034
0035 set editor "gvim"
0036 P_menu
Page 36
March 31, 2002 Introduction to Tcl/Tk
14.6 canvas
0001 #!/usr/bin/wish
0002 #-----------------------------------------------------------
0003 # example: ex_canvas.tcl
0004 # this example was combined from examples 34-1 and 34-2
0005 # Practical Programming in Tcl and Tk, 3rd Edition
0006 # written by Brent Welsh
0007 #-----------------------------------------------------------
0008 proc Scrolled_Canvas { c args } {
0009 frame $c
0010 eval {canvas $c.canvas \
0011 -xscrollcommand [list $c.xscroll set] \
0012 -yscrollcommand [list $c.yscroll set] \
0013 -highlightthickness 0 \
0014 -borderwidth 0} $args
0015 scrollbar $c.xscroll -orient horizontal \
0016 -command [list $c.canvas xview]
0017 scrollbar $c.yscroll -orient vertical \
0018 -command [list $c.canvas yview]
0019 grid $c.canvas $c.yscroll -sticky news
0020 grid $c.xscroll -sticky ew
0021 grid rowconfigure $c 0 -weight 1
0022 grid columnconfigure $c 0 -weight 1
0023 return $c.canvas
0024 }
0025
0026 proc CanvasHello {} {
0027 set can [Scrolled_Canvas .c -width 400 -height 100 \
0028 -scrollregion {0 0 800 400}]
0029 pack .c -fill both -expand true
0030 # Create a text object on the canvas
0031 $can create text 50 50 -text "Hello, World!" -tag movable
0032 # Bind actions to objects with the movable tag
0033 $can bind movable <Button-1> {CanvasMark %x %y %W}
0034 $can bind movable <B1-Motion> {CanvasDrag %x %y %W}
0035 }
0036
0037 proc CanvasMark { x y can } {
0038 global canvas
0039 # Map from view coordinates to canvas coordinates
0040 set x [$can canvasx $x]
0041 set y [$can canvasy $y]
0042 # Remember the object and its location
0043 set canvas($can,obj) [$can find closest $x $y]
0044 set canvas($can,x) $x
0045 set canvas($can,y) $y
0046 }
0047
0048 proc CanvasDrag { x y can } {
0049 global canvas
0050 # Map from view coordinates to canvas coordinates
0051 set x [$can canvasx $x]
0052 set y [$can canvasy $y]
Page 37
March 31, 2002 Introduction to Tcl/Tk
Page 38
March 31, 2002 Introduction to Tcl/Tk
References
[1] Welch, Brent B., Practical Programming in Tcl and Tk, Third Edition, ISBN 0-13-022028-0, Prentice Hall, Upper
Saddle River, NJ, 2000
[2] Nelson, Christopher, Tcl/Tk Programmers Reference, ISBN 0-07-212004-5, Osborne McGraw-Hill, 2600 Tenth
Street, Berkeley, CA, 94710, 2000
[3] Flynt, Clif, Tcl/Tk for Real Programmers, ISBN 0-12-261205-1, Academic Press, 1999
[4] Young, David H., The Visual Tcl Handbook, ISBN 013461674X, Prentice Hall, 1996
[5] Ousterhout, Dr. John K., Tcl and the Tk Toolkit, 0-201-63337-X, Addison-Wesley Publishing, 1994
[6] Ousterhout, Dr. John K., The History of Tcl, http://tcl.activestate.com/advocacy/tclHistory.html
[7] USENET, comp.lang.tcl
[8] Tcl Consortium, http://www.tclconsortium.org/resources/
[9] Scriptics, http://www.scriptics.com/
[10] ActiveState, http://www.activestate.com/
[11] ActiveState Tcl, http://tcl.activestate.com/
[12] Tcl for EDA, http://www.tclforeda.net/
Page 39