next up previous contents index
Next: HELP Up: SIC Language Internal Help Previous: EXIT   Contents   Index


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  Vari-
    able),  or  until  a logical expression becomes false (FOR /WHILE).  The
    last character of the prompt becomes a ':' instead of '>', and all  sub-
    sequent  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  sub-
    stituted  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 vari-
    ables are undefined outside the loop, and must  not  be  previously  de-
    fined.  Invalid ranges are ignored at execution time: e.g. in the previ-
    ous 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 er-
    ror.

    Conditional loops execute until the logical  expression  becomes  false.
    For example FOR /WHILE .TRUE. will execute forever.


Gildas manager 2015-03-01