ITERATE command

The Iterate (ITERATE) command can be used to skip the remaining commands in an active DOWHILE, DOUNTIL, or DOFOR group.

ITERATE is not valid with simple DO command groups.

An Iterate (ITERATE) command without a label will skip to the ENDDO of the innermost active DO group. Specifying a label skips to the ENDDO of the DO associated with the label.

The following illustrates use of the Iterate (ITERATE) command:

DO_1:
DO_2:DOWHILE &LGL
DO_3:  DOFOR &INT FROM(0) TO(99)
         .
         .
         .
         IF (&A *EQ 12) THEN (ITERATE DO_1)
         .
         . /* Not processed if &A equals 12        */
         .
         IF (&A *GT 12) ITERATE 
         .
         .  /* Not processed if &A greater than 12 */
         .
       ENDDO
         .
         .
         .
       IF (&A *LT 0) (ITERATE DO_1)
         .
         . /* Not processed if &A less than zero   */
         .
     ENDDO

In this example, the labels DO_1 and DO_2 are associated with the DOWHILE group. They can be specified on an Iterate (ITERATE) command appearing in either the DOWHILE or DOFOR group. When &A is equal to 12, the ITERATE DO_1 command is run. Processing continues at the ENDDO associated with the DOWHILE command. The value of &LGL is evaluated and, if true, continues with the DOFOR following the DOWHILE. If &LGL is false, processing continues with the CL command following the second ENDDO.

If &A is not equal to 12 but is greater than 12, processing continues with the ENDDO of the DOFOR group. The value of &INT is incremented and compared to the ending value of 99. If &INT is less than or equal to 99, processing continues with the first command following the Do For (DOFOR) command. If &INT is greater than 99, processing continues with the next command following the first ENDDO.

When the third IF command is processed and &A is less than zero, processing continues with the second ENDDO. The value of &LGL is evaluated and, if false, control passes to the command following the ENDDO. If true, processing resumes with the Do For (DOFOR) command following the DOWHILE.

Related information
CL command finder
Iterate (ITERATE) command