Tutorial by Examples

In Tcl, a control structure is basically just another command. This is one possible implementation of a do ... while / do ... until control structure. proc do {body keyword expression} { uplevel 1 $body switch $keyword { while {uplevel 1 [list while $expression $body]} u...
if expr1 ?then? body1 elseif expr2 ?then? body2 ... ?else? ?bodyN? exprN is an expression that evaluates to a boolean value. bodyN is a list of commands. set i 5 if {$i < 10} { puts {hello world} } elseif {$i < 70} { puts {enjoy world} } else { puts {goodbye world} } for sta...
foreach varlist1 list1 ?varlist2 list2 ...? body foreach is a powerful control structure that allows looping over a list or multiple lists. set alpha [list a b c d e f] foreach {key} $alpha { puts "key: $key" } Multiple variable names may be specified. set alphaindexes [list a ...

Page 1 of 1