8. Control Flow
This chapter describes the Tcl commands for controlling the flow of execution in a script. Tcl’s control flow commands are similar to the control flow statements in the C programming language and the Unix shell csh
, including if
, while
, for
, foreach
, switch
, and eval
.
8.1 Commands Presented in This Chapter
You can use the following commands to control the flow of execution in a Tcl script:
• break
Terminates the innermost nested looping command.
• continue
Terminates the current iteration of the innermost looping command and goes on to the next iteration of that command.
• eval
arg
?
arg arg
...?
Concatenates all of the arg
s with separator spaces, then evaluates the result as a Tcl script and returns its result.
• for
init test ...
Get Tcl and the Tk Toolkit, Second Edition 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.