-
Book Overview & Buying
-
Table Of Contents
Tcl/Tk 8.5 Programming Cookbook
The for command performs the actions desired as long as the condition is met. In this manner the condition is repeatedly evaluated and the actions are performed as long as the condition remains true. The syntax of the for statement consists of three arguments (start, test, and next) and a body:
for start test next body
The start, next, and the body arguments must be in the form of Tcl command strings with test as an expression string. The for command invokes the interpreter to execute start. Then, it repeatedly evaluates test as an expression. While the result is non-zero, it invokes the Tcl interpreter on body. Then, it invokes the interpreter on next and repeats the loop. The command terminates when test is evaluated to 0.
Please note that the condition should always be enclosed within braces to avoid command substitution prior to processing, which may result in the dreaded infinite loop.
In the following recipe, we will create a Tcl script to be called from...
Change the font size
Change margin width
Change background colour