COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-173
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 the specified set of statements is executed. This is
considered the inner loop. Each iteration of the inner loop ends by evaluating
condition-2.
°
If its value is FALSE, vary-2 is augmented by the specified increment or
decrement (the value of step-2 ), and a cycle is performed.
°
If its value is TRUE, condition-1 is evaluated.
°
If the value of condition-1 is FALSE, vary-1 is augmented by the
specified increment or decrement (the value of step-1 ), vary-2 is
initialized with the current value of base-2, and the inner loop is entered
again.
°
Whenever the evaluation of condition-1 results in TRUE, execution of
the statement terminates.
Figure 9-9. Execution of a PERFORM VARYING Statement
With a TEST AFTER 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
VST512.vsd