Loops
Keywords: sic

Next: Structured Programming and Logical Up: SIC as a programming Previous: Procedures (or Command Files) Contents Index

###
Loops

            FOR Variable List

opens a `FOR-NEXT` loop to be executed for values given in the list.

This command may have the following format :

            FOR I n1 n2 n3 to n4 by n5 n6 to n7

where I is the loop variable name. Loop variables must not be previously defined, and are undefined when the loop execution is finished. The prompt changes to `'SIC_n: '`, where n is the current SIC execution level, and all subsequent commands until `NEXT` are the body of the loop. The loop variable can be used as any other SIC variable, e.g. in arithmetic expressions such as EXP(-(I+3.5)**2). In addition, it can be used in a formatted way when it is included between quotes, e.g. in `NAME.EXT.'I'`. In this case, the substitution occurs also within the character strings (see ``Implicit Formatting''). The commands are echoed to the user's terminal if the `VERIFY` switch is set `ON`.

Up to 127 loop, procedure or `IF` block levels can be nested, and there is no restriction upon the loop and procedure nesting, e.g.

              SIC> FOR I List1
              SIC> FOR J List2
              SIC> ..
              SIC> NEXT
              SIC> FOR J List3
              SIC> ...
              SIC> NEXT
              SIC> NEXT

is perfectly valid.

            FOR /WHILE Logical_Expression

This is another possible syntax for `FOR-NEXT` loops. The loop is executed conditionally provided ``Logical_Expression'' is `TRUE`. ``Logical_Expression'' must be any valid logical expression, possibly including arithmetic sub-expressions in it.

Next: Structured Programming and Logical Up: SIC as a programming Previous: Procedures (or Command Files) Contents Index