 Iterate instruction iterate [name]; where name is a non-numeric symbol. iterate alters the flow of control within a loop construct. It may only be used in the body (the first instructionlist) of the construct. Execution of the instruction list stops, and control is passed directly back up to the loop clause just as though the last clause in the body of the construct had just been executed. The control variable (if any) is then stepped (iterated) and termination conditions tested as normal and the instruction list is executed again, unless the loop is terminated by the loop clause. If no name is specified, then iterate will step the innermost active loop. If a name is specified, then it must be the name of the label, or control variable if there is no label, of a currently active loop (which may be the innermost), and this is the loop that is iterated. Any active do, loop, or select constructs inside the loop selected for iteration are terminated (as though by a leave instruction). Example: loop i=1 to 4 if i=2 then iterate i say i end /* Would display the numbers: 1, 3, 4 */ Notes: - A loop is active if it is currently being executed. If a method (even in the same class) is called during execution of a loop, then the loop becomes inactive until the method has returned. iterate cannot be used to step an inactive loop.
- The name symbol, if specified, must exactly match the label (or the name of the control variable, if there is no label) in the loop clause in all respects except case.
|