COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-172
PERFORM VARYING
When multiple AFTER phrases appear, the mechanism is the same as for one
AFTER phrase except:
°
In secondary AFTER phrases, vary-2 is also initialized with the value of
base-2 in its associated FROM phrase at the beginning of execution of the
PERFORM statement.
°
In the inner loop (as described earlier), the step “a cycle is performed” is
replaced by “execution proceeds to the next inner loop.”
°
The logic of the next inner loop parallels that of the first inner loop except for:
°
Its condition plays the role of condition-2.
°
The next vary-2 is augmented by the current value of its step-2 after
each cycle is performed.
°
The next vary-2 is initialized with the current value of the base-2 in its
associated FROM phrase when the value of its condition is TRUE.
After termination of a PERFORM statement with multiple AFTER phrases, vary-1
has the value assigned, either by initialization or augmentation, at the point where
the evaluation of condition-1 gave a result of TRUE, and each vary-2 has
the value assigned by its last initialization from its associated base-2.
•
Execution of PERFORM VARYING with TEST AFTER Specified
When no AFTER phrase list appears, vary-1 is initialized with the value of
base-1 at the beginning of execution of the PERFORM statement. The first cycle
is then performed. After the completion of each cycle, condition-1 is evaluated
to determine whether or not to perform another cycle. Whenever the evaluation of
condition-1 results in TRUE, execution of the statement terminates. If the
evaluation of condition-1 results in FALSE, the value of vary-1 is augmented
by the specified increment or decrement (the value of step-2 ), and another cycle
is performed.
After termination of the PERFORM statement, vary-1 has the value it contained
at the end of the last execution of the range of the PERFORM statement.