Next: REPEAT Statement, Previous: NCASE Statement, Up: Statements [Contents][Index]
The for
statement repeats a statement a specific number of times.
FOR var = expr1, expr2 [, expr3] [ DO ] statement
Variable var
is the loop variable. It is assigned the
value of expr1
. Then the statement statement
is executed. Then the loop variable is incremented by
expr3
, if specified, or by one otherwise. If the value of
the loop variable is now greater than that of expr2
, then
the loop is finished and control passes to the next statement.
Otherwise, the loop is repeated.
For example,
LUX>FOR i = 1,5 T,i*i 1 4 9 16 25 LUX>