next up previous index
Next: Loops Up: Basic Tcl Previous: String Manipulation Commands

Control Structures

if   test body
If test evaluates to nonzero, execute body. It can also be followed by elseif body and else body items:
if {$a < 0} {
    puts negative
} elseif {$a < 100} {
    puts small
} else {
    puts large
}
Note that elseif must be used, else if is not accepted.

eval   arg ?arg ... ?
The values of all arguments are concatenated with space separators and the resulting list is evaluated as a Tcl script. The main usage of this command is to enforce another parsing level or metacalling. Note that list values may have to be passed using the list   or concat   command:
% set a {a b c d}
a b c d
% eval llength $a
wrong # args: should be "llength list"
% eval llength [list $a]
4


Micha Meier
Tue Jul 2 09:49:39 MET DST 1996