Chapter 6. Control Structure Commands
This chapter describes the Tcl commands that implement control structures: if
, switch
, foreach
, while
, for
, break
, continue
, catch
, error
, and return
.
Control structure in Tcl is achieved with commands, just like everything else. There are looping commands: while
, foreach
, and for
. There are conditional commands: if
and switch
. There is an error handling command: catch
. Finally, there are some commands to fine-tune control structures: break
, continue
, return
, and error
.
A control structure command often has a command body that is executed later, either conditionally or in a loop. In this case, it is important to group the command body with curly braces to avoid substitutions at the time the control structure ...
Get Practical Programming in Tcl and Tk, Fourth 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.