Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
edu/~keith//tcl-course/#emacs
T cl (pronounced Tickle) is a
general purpose program-
ming language originally in-
cations (C programs for example)
as a configuration and extension
language. This minimizes the
Automatic Memory
Management
TCL_Notes page 1 of 6
http://freewrap.sourceforge.net/
freeWrap
Builds stand-alone TCL/TK executables. No compiler required!
OR Use it as a single-file WISH shell
The freewrap program turns freewrap to behave as a stand- freeWrap includes several
TCL/TK scripts into single-file alone, single-file WISH that can Windows-specific commands
binary executable programs. be used to run any TCL/TK script. for installing your wrapped
applications.
The resulting program can be dis- freewrapTCLSH can be used
tributed to machines that do not as a single file stand - alone These commands can be used to
have TCL/TK installed. The exe- TCLSH shell determine the location of Windows'
cutable will also work on mach- special directories and make for
ines that have TCL/TK installed Renaming the freewrapTCLSH easy creation of file extension
program to some other file name associations and shortcuts.
but will use its own TCL / TK
causes freewrapTCLSH to behave
"image". freeWrap itself does not
as a a stand-alone, single-file freeWrap includes commands
need TCL / TK installed to run.
TCLSH shell that can be used to for ZIP file creation and
run any TCL script. extraction.
The freeWrap program is a TCL/
TK script that has been attached Due to freeWrap's use of the ZIP
Shared libraries can be used
to a single-file version of the WISH Virtual File System any ZIP
with your wrapped programs.
shell program. The single-file archive can be opened so its
WISH was created with the help of FreeWrapped applications can contents look like a simple file
the ZIP Virtual File System (ZVFS) load TCL/TK shared library exten- subdirectory. The archive's files
source code provided by D. Richard sions that have been compiled are automatically decompressed
Hipp. The ZVFS code has been with the STUBS interface. when read with TCL commands.
adapted for use with TCL's virtual
The makeZIP command allows
file system interface. Your wrapped programs can
creation and modification of ZIP
be customized with your own
Easy, one-step wrapping. archives from within your free-
window icons.
Wrapped application.
FreeWrap consists of a single exe- The Windows version of freeWrap
cutable file. There is no setup re- can incorporate your own custom- Availability
quired. Wrapping is accomplished ized icon into your wrapped app- FreeWrap executables are freely
with a single command. lication. available for both Linux and
Windows 95 / 98 / NT / 2000 / XP.
freewrapTCLSH can be used No license fees for
Instructions and source code for
to wrap TCL-only scripts. wrapped programs.
building freeWrap on both Win-
FreewrapTCLSH creates a single There are no license fees associ- dows and UNIX platforms are
executable file from a TCL script. ated with freeWrap. See the free- included in the freeWrap source
The wrapping syntax is identical to Wrap documentation [ 1 ] code distribution. See the Down-
the freewrap program. This produ- loads table below for specifics [ 2 ]
ces a console-only type of program. Cross-platform generation
of programs is supported. Versions of freeWrap that include
freeWrap can be used as a the BLT and TkTable extensions
The -w "wrap using" option allows to TCL/TK are also available for
single file stand-alone WISH
cross-platform creation of wrapped download. TCL-only versions of
Renaming the freewrap program applications without the use of the freeWrap are available also for
to some other file name causes target computer system. wrapping TCL (non-TK) scripts. □
TCL_Notes page 2 of 6
TCL Fundamentals http://www.beedub.com/book/3rd/Tclintro.pdf
Brent Welch, K. Jones and J. Hobbs from: http://www.beedub.com/book/ Sample chapters in html, pdf.
«Tcl is a string-based command language. The language has only a few fundamental constructs and
relatively little syntax, which makes it easy to learn. The Tcl syntax is meant to be simple. Tcl is designed
to be a glue that assembles software building blocks into applications. A simpler glue makes the job easier.
In addition, Tcl is interpreted when the application runs. The interpreter makes it easy to build and refine
your application in an interactive manner. A great way to learn Tcl is to try out commands interactively.»
TclTutor http://www.msen.com
© Copyright 1995,2000 by Clif Flynt
«TclTutor is a Computer Aided Instruction package that teaches the basics of the Tcl
programming language. The 40+ lessons in this package can be completed in under 10
minutes each. You'll be ready to start simple programs after the first half dozen lessons.
This program will teach you the syntax for the main Tcl commands and options.» Available
for Mac OS8-10, Unix and Win95+. To download for Windows, pick «Self-Installing Zip» or
(preferably) « Free-Wrapped Executable. »
Programming:Tcl http://en.wikibooks.org/wiki/Programming:Tcl_Print_version
by Richard Suchenwirth
«Tcl is an interpreted language with programming features, available for Unix, Windows and the Mac [8-10]
OSes. Tk the associated toolkit is an easy, efficient way to develop window[ed-type] based applications and has
a wide user base. Ease of learning Tcl/Tk make it most appropriate for teaching GUI design. This cookbook
provides examples with comments so a novice user quickly climbs the learning curve in a relatively short time.»
TCL_Notes page 3 of 6
http://www.linuxfocus.org/English/September1999/article110.html
For a scripting language, Tcl has a simple syntax. Grouping and Substitution
cmd arg arg arg The Tcl syntax is used to guide the Tcl parser
A Tcl command is formed by words separated through three steps: argument grouping, result sub-
by white space. The first word is the name of the stitution, and command dispatch.
command, and the remaining words are argu-
ments to the command. 1. Argument grouping. Tcl needs to determine
how to organize the arguments to the commands.
$foo In the simplest case, white space separates argu-
The dollar sign ($) substitutes the value of a vari- ments. The quotation marks and braces syntax is used
able. In this example, the variable name is foo. to group multiple words into one argument. In the
previous example, double quotation marks are used
[clock seconds] to group a single argument to the puts command.
Square brackets execute a nested command. For
example: if you want to pass the result of one com- 2. Result substitution. After the arguments are
mand as the argument to another, you use this syn- grouped, Tcl performs string substitutions. Put
tax. In this example, the nested command is clock simply: it replaces $foo with the value of the vari-
seconds, which gives the current time in seconds. able foo, and it replaces bracketed commands with
their result. That substitutions are done after group-
"some stuff"
ing is crucial. This sequence ensures that unusual
Double quotation marks group words as a single ar- values do not complicate the structure of commands.
gument to a command. Dollar signs and square brack-
ets are interpreted inside double quotation marks. 3. Command dispatch. After substitution, Tcl
uses the command name as a key into a dispatch
{some stuff}
table. It calls the C procedure identified in the table,
Curly braces also group words into a single ar- and the C procedure implements the command.
gument. In this case, however, elements within You also can write command procedures in Tcl.
the braces are not interpreted. There are simple conventions about argument pass-
\
ing and handling errors.
The backslash ( \ ) is used to quote special char-
Another Example
acters. For example: \n generates a newline.
The backslash also is used to "turn off" the set i 0
special meanings of the dollar sign, quotation while {$i < 10} {
marks, square brackets, and curly braces. puts "$i squared = [expr $i*$i]"
incr i
}
A Little Example
Here, curly braces are used to group arguments
Below is a Tcl command that prints the current without doing any substitutions. The Tcl parser
time. It uses three Tcl commands: set, clock, and
knows nothing special about the while command.
puts. The set command assigns the variable. The
clock command manipulates time values. The puts
It treats it like any other command. It is the
command prints the values. implementation of the while command knows that
the first argument is an expression, and the second
set seconds [clock seconds] argument is more Tcl commands. The braces group
puts "The time is [clock format $seconds]" two arguments: the boolean expression that controls
the loop; and the commands in the loop body.
Note that you do not use $ when assigning a variable.
Only when you want the value do you use $. The We also see two math expressions: the boolean
seconds variable isn't needed in the previous example. comparison and multiplication. The while command
You could print the current time with one command: automatically evaluates its first argument as an
expression. In other cases you must explicitly use
puts "The time is [clock format [clock
seconds]]" the expr command to perform math evaluation.
TCL_Notes page 4 of 6
Command Dispatch
Lastly, Tcl calls something else to do the hard work. arguments from the Tcl command and return a new
We've seen that Tcl uses expr to perform math string as their result. It is very easy to write C com-
functions; puts to handle output functions; and set mand procedures. They can do everything from
accessing databases to creating graphical user
to assign variables. These Tcl commands are imple-
interfaces. Tcl, the language, doesn't really know
mented by a C procedure that has registered itself what the commands do. It just groups arguments,
with Tcl. The C command procedures take the string substitutes results, and dispatches the commands.
More Reading
http://www.beedub.com/book/2nd/tclintro.doc.html
http://www.linbox.com/ucome.rvt/any/doc_distrib/tcltk-8.3.2/TclCourse/TclWeek1.html
http://www.linbox.com/ucome.rvt/any/doc_distrib/tcltk-8.3.2/TclCourse/TclWeek2.html
http://www.linbox.com/ucome.rvt/any/doc_distrib/tcltk-8.3.2/TclCourse/TclWeek3.html
http://www.linbox.com/ucome.rvt/any/doc_distrib/tcltk-8.3.2/TclCourse/TclWeek4.html
http://www.linbox.com/ucome.rvt/any/doc_distrib/tcltk-8.3.2/TclCourse/TclWeek5.html
Brent B. Welch is the author of "Practical Programming in Tcl and Tk." Welch received a BS in
Aerospace Engineering at the University of Colorado, Boulder, in 1982 and an MS in Computer Science
at the University of California, Berkeley, in 1986 and a PhD in Computer Science at the University of
California, Berkeley, in 1990. Previously Welch was a member of research staff at Xerox PARC work-
ing on distributed systems, and later a member of the Tcl/Tk team at Sun Microsystems Laboratories.
He is a member of the ACM and the IEEE Computer Society. Home Page: http://www.beedub.com/
TCL_Notes page 5 of 6
http://www.infoworld.com/cgi-bin/displayNew.pl?/petrel/980928np.htm
[ excerpts ]
The salacious truth of the scripting paradigm shift to Tcl/Tk and Python
TCL_Notes page 6 of 6