-
Book Overview & Buying
-
Table Of Contents
Tcl/Tk 8.5 Programming Cookbook
While the continue keyword is not a control construct in itself, it allows you to affect the control flow.
In the following recipe, we will create a Tcl script, to be called from the command line, that increments the value of x and prints out the value as in the for command recipe. However, the output will be skipped when x is equal to 5.
Create a text file named continue.tcl that contains the following commands.
Please note that within the comparison used to invoke the continue keyword, I have added a blank line for clarification. This is not needed for the continue statement but does make the output more legible as well as illustrating the usage of conditional check to perform additional actions.
for {set x 1} {$x < 11} {incr x} {
if {$x == 5} {
puts " "
continue
}
puts "x = $x"
}
Now invoke the script using the following command line:
% tclsh85 continue.tcl x = 1 x = 2 x = 3 x = 4 x = 6 x = 7 x = 8 x = 9 x = 10
The action was invoked 10...
Change the font size
Change margin width
Change background colour