Name
for
- for
start test next body
Implement a loop construct, similar to the for loop in C.
start
Command string, executed once at beginning
test
Expression string, for loop test
next
Command string, executed at end of each iteration
body
Command string, executed in each loop iteration
The interpreter executes
start
once. Then it evaluates the expressiontest
; if the result is zero, it returns an empty string. If non-zero, it executesbody
, thennext
, and repeats the loop starting withtest
again.
Example
for {set i 0} {$i < 100} {incr i} { puts $i }
Get Tcl/Tk in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.