Tcl installation

There are several versions Tcl Shell are available, including from ActiveState for Windows platform. Unix distributions (Redhat Linux, Ubuntu, Debian etc) come with preinstalled Tcl interpreter. You may choose any, depending on your system. Some good leads are also available at website. The "TK" stands for tool kit.

Once Tcl/Tnm is installed, you may launch the Tcl shell using tclsh from the Windows Start menu. It will open a command prompt like window that accepts Tcl commands. Tnm is the Tcl network management tool. In Linux you may simply type tclsh in any terminal window and it will open Tcl shell. Kindly note that this Tcl shell tclsh is different from tcsh in Linux, which is an advanced C-shell.

In the Tcl Shell, Try these

Type ? (for quick help; also look into the /doc folder for extensive help)
puts "Hello World\n" ( prints hello world on screen)
exit (get out of Tcl shell)

Tcl Syntax

In Tcl, all data are represented as strings

Command syntax:
Command arg1 arg2 ...

Each Tcl command call is a sentence of the form :
command arg1 arg2 arg3 ...

arg evaluation

Literal constants [integers, string values ...]

Variable replaced by its value

The Tcl evaluator take each word of this sentence and evaluate it. After evaluation of each word, the first word (command) is considered to be a function name and this function is executed with as arguments the following words.

To evaluate a word, the interpreter has to do the following substitutions in the word string :

If the word is surrounded by " ", this word may contain spaces, but substitution is still applicable inside the quotations. Inside the quotation, there may be spaces and carriage returns.

If a word is surrounded by { }, this word is unaffected (substitution is thus not applicable on this word). Inside the braces, there may be spaces and carriage returns. Moreover, the { } braces may be nested.

If a part of the word is surrounded by [ ], this part is considered as a command sentence : the text within the brackets is evaluated as a Tcl command and replaced with the result.

where substitution is applicable, every string beginning with $ is replaced with the variable represented by this string. This string is ended by a space, a '-' or a ','.

Go to Tcl-page 3... Back to Tcl-page 1.