COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-170
PERFORM VARYING
When one AFTER phrase appears, vary-1 and vary-2 are initialized with the
values of base-1 and base-2, respectively, at the beginning of execution of the
PERFORM statement. Then either:
°
If condition-1 is TRUE, execution of the statement terminates without ever
proceeding to the inner loop (without performing any cycles).
°
If the initial value of condition-1 is FALSE, execution proceeds to the inner
loop of the PERFORM statement logic.
Each iteration of the inner loop begins with an evaluation of condition-2:
°
If its value is FALSE, a cycle is performed, vary-2 is augmented by the
specified increment or decrement (the value of step-2 ), and control returns
to the top of the loop.
°
If the value of condition-2 is TRUE, no cycle is performed, vary-1 is
augmented by the specified increment or decrement (the value of step-1 ),
vary-2 is initialized to base-2, and the inner loop terminates.
Figure 9-7. Execution of a PERFORM VARYING Statement
With a TEST BEFORE Phrase and Without an AFTER Phrase List
Exit
Enter
condition-1
?
Set vary-1 to
current base-1
value.
Execute the
range of the
PERFORM.
Augment
vary-1 with
step-1 .
TRUE
FALSE
VST510.vsd