Next: HELP
Up: SIC Language Internal Help
Previous: EXIT
FOR
[SIC\]FOR Loop_Variable n1 n2 n3 TO n4 BY n5 n6 TO n7
or
[SIC\]FOR /WHILE Logical_Expression
Open a FOR-NEXT loop to be executed for values in the list (FOR
Variable), or until a logical expression becomes false (FOR /WHILE).
The last character of the prompt becomes a ':' instead of '>', and all
subsequent commands typed in until NEXT are the body of the loop. Up
to nine loops may be nested in any way. The index of the loop will be
substituted to the loop variable Loop_Variable during loop execution.
The substitution occurs also within character strings if the loop
variable name is included between single quotes. Note that the index
values may be real.
[SIC\]FOR Loop_Variable n1 n2 n3 TO n4 BY n5 n6 TO n7
The loop specified in this example will execute for the following values
of the index :
n1
n2
n3, n3 + n5, n3 + 2 n5, n3 + 3 n5, ... , n4
n6, n6 + 1, n6 + 2, ... , n7
(assuming that n4-n3 is a multiple of n5, n7-n6 an integer). Loop
variables are undefined outside the loop, and must not be previously
defined. Invalid ranges are ignored at execution time: e.g. in the
previous example, the loop would not be executed for n3 TO n4 BY n5 if
n5*(n4-n3) < 0, but no error is signaled. Increments of 0 produce an
error.
Conditional loops execute until the logical expression becomes false.
For example FOR/WHILE .TRUE. will execute forever...
Gildas manager
2001-04-18