Kilowatt Software's
Classic Rexx Tutorial
Language Level 4.00 (TRL-2)

Advanced iteration concepts

In addition to the standard set of iterative do looping capabilities, Rexx also has two additional loop refinements -- the iterate and leave instructions.

Iterate instruction

An iterate instruction causes the associated loop to proceed with its next cycle, as though the corresponding end instruction had been encountered. A loopControlVariableName can be specified with the iterate instruction, only when a counted do instruction group has the named control variable. This name is compared versus all active counted loop control variables. The comparison of these names is performed independent of character case. When a A loopControlVariableName is specified, the next iteration of the associated loop ensues. When a loopControlVariableName is absent, the next iteration of the innermost active loop ensues.

Two examples are provided below. The first shows every other line in the input stream. The second is more eccentric.

Leave instruction

An leave instruction concludes its associated loop. Execution continues with the instruction that follows the end instruction of the associated loop. A loopControlVariableName can be specified with the leave instruction, only when a counted do instruction group has the named control variable. This name is compared versus all active counted loop control variables. The comparison of these names is performed independent of character case. When a A loopControlVariableName is specified, that do instruction group is concluded. When a loopControlVariableName is absent, the innermost active loop is concluded.

Two examples are provided below. The first locates an excessively long line in the input stream. The second is more eccentric.


Kilowatt Software's -- Classic Rexx Tutorial -- Back to top
Click here if you have any comments or questions regarding this tutorial

Last updated on: 9 Aug 2002