/MACRO_SYNTAX_Looping

Macro statements for construction loops.

/MACRO/SYNTAX/Looping/DO

Loop incrementing a loop counter.

DO loop = start_expr, finish_expr [, step_expr ] statements ENDDO

The step size (setp_expr) defaults to "1". The arithmetic expressions involved can be floating point values but care must be taken of rounding errors.

Note that "DO i=1,0" results in zero iterations and that the expressions are evaluated only once.

/MACRO/SYNTAX/Looping/FOR

Loop over items in an expression list.

FOR name IN expr_1 [ expr_2 ... expr_n ] statements ENDFOR

In a FOR-loop the number of iterations is determined by the number of items in the blank-separated expression list. The expression list must not be empty. One by one each expression evaluated and assigned to the variable name before the statements are executed.

The expressions can be of any type: arithmetic, string, or garbage expressions, and they do not need to be all of the same type. In general each expression is a single list item even if the result contains blanks.

The variable [*] is treated as a special case being equivalent to the expression list "[1] [2] ... [n]" which allows yet another construct to traverse the macro arguments:

FOR arg IN [*] ... ENDFOR

/MACRO/SYNTAX/Looping/REPEAT

Loop until condition becomes true.

REPEAT statements UNTIL expression

The body of a REPEAT-loop is executed at least once and iterated until the boolean expression evaluates to true.

/MACRO/SYNTAX/Looping/WHILE

Loop while condition is true.

WHILE expression DO statements ENDWHILE

The WHILE-loop is iterated while the boolean expression evaluates to true. The loop body is not executed at all if the boolean expression is false already in the beginning.

/MACRO/SYNTAX/Looping/BREAKL

Terminate a loop.

BREAKL [ level ]

Allows to terminate a loop prematurely. The BREAKL continues executing after the end clause of a DO, FOR, WHILE, or REPEAT block, where "level" indicates how many nested constructs to terminate. The default value level=1 terminates the innermost loop construct.

/MACRO/SYNTAX/Looping/NEXTL

Continue with next loop iteration.

NEXTL [ level ]

Allows to continue with the next loop iteration without executing the rest of the loop body. Execution continues just before the end clause of a DO, FOR, WHILE, or REPEAT block, where "level" indicates how many nested blocks to skip. The default value level=1 skips to the end of the innermost loop construct.