Continuing a procedure

While the continue keyword is not a control construct in itself, it allows you to affect the control flow.

How to do it…

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 ...

Get Tcl/Tk 8.5 Programming Cookbook 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.