Varying two identifiers

The topic lists steps of varying two identifiers.


PERFORM PROCEDURE-NAME-1 THROUGH PROCEDURE-NAME-2
      VARYING IDENTIFIER-2 FROM IDENTIFIER-3
            BY IDENTIFIER-4 UNTIL CONDITION-1
         AFTER IDENTIFIER-5 FROM IDENTIFIER-6
            BY IDENTIFIER-7 UNTIL CONDITION-2
  1. identifier-2 and identifier-5 are set to their initial values, identifier-3 and identifier-6, respectively.
  2. condition-1 is evaluated as follows:
    1. If it is false, steps 3 through 7 are executed.
    2. If it is true, control passes directly to the statement following the PERFORM statement.
  3. condition-2 is evaluated as follows:
    1. If it is false, steps 4 through 6 are executed.
    2. If it is true, identifier-2 is augmented by identifier-4, identifier-5 is set to the current value of identifier-6, and step 2 is repeated.
  4. procedure-name-1 and procedure-name-2 are executed once (if specified).
  5. identifier-5 is augmented by identifier-7.
  6. Steps 3 through 5 are repeated until condition-2 is true.
  7. Steps 2 through 6 are repeated until condition-1 is true.

At the end of PERFORM statement execution:

  • identifier-5 contains the current value of identifier-6.
  • identifier-2 has a value that exceeds the last-used setting by the increment or decrement value (unless condition-1 was true at the beginning of PERFORM statement execution, in which case, identifier-2 contains the current value of identifier-3).

The following figure illustrates the logic of the PERFORM statement when two identifiers are varied with TEST BEFORE.

This figure illustrates PERFORM varying two identifiers with TEST BEFORE, as described in text above for varying two identifiers.

The following figure illustrates the logic of the PERFORM statement when two identifiers are varied with TEST AFTER.