programming.nbk: Home | Index | Next Page: Tcl: for | Previous Page: Tcl: Control Structures


 Tcl: evaluation and quoting

Each line of Tcl is interpreted as a separate command.

The basic Tcl syntax is:

    procedure_name arg arg arg

Arguments are evaluated left to right.

If you want to call another procedure to generate one of the args, you need to surround that procedure and it's arguments with square brackets:

    procedure_name arg [sub_procedure_name arg arg] arg

If an argument consists of a single word (no spaces) it is not neccessary to delimit it. If the arguement consists of multiple words delimiters are needed. Strings may be delimited with double quotes or curly brackets. If double quotes are used, Tcl looks for dollar signs and square brackets in the string. This allows variables and procedures to be evaluated in the string:

    puts "ten times your balance is [expr 10 * $checking_account_balance] dollars"

If you need a actual dollar sign in the string, escape it as \$$.
If you need a actual square bracket in the string, escape them as \[ and \].

If you use curly brackets to delimit the string, Tcl does not look inside the string.

If you must break a line of tcl into more than one line, the \ is used at the end of the line as a continuation character.

Semicolons can be used between multiple commands on a single line.

Variables and procedure names are case sensitive.


programming.nbk: Home | Index | Next Page: Tcl: for | Previous Page: Tcl: Control Structures


Notebook exported on Monday, 7 July 2008, 18:56:06 PM Eastern Daylight Time