Previous Topic

Next Topic

Book Contents

Tcl Commands Format

Tcl scripts are made up of commands separated by new lines or semicolon (;).

The basic syntax for a Tcl command is:

command $arg1 $arg2 ...

command

name of the Tcl command or user-defined procedure

$arg1 $arg2 ...

arguments for the command

Tcl allows any argument to be nested command:

command [nested-command1] [nested-command2]

where the [] are used to delimit the nested commands. The Tcl interpreter will first evaluate the nested commands and will then evaluate the outer command with the results to the nested commands.

The most basic command in Tcl is the set command:

set variable $value

for example:

set a 5

The Tcl interpreter regards a command starting with the pond sign (#) to be a comment statement, so it does not execute anything following the #. For example:

# this command assigns the value 5 to the variable a

set a 5

The pound sign and the semicolon can be used together to put comments on the same line as the command. For example:

set a 5; # this command assigns the value 5 to the variable a

Previous Topic

Next Topic