COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-169
PERFORM VARYING
imperative-statement
is defined in Imperative Statement.
END-PERFORM
ends the scope of the PERFORM statement, causing the PERFORM to be a
delimited-scope statement. If the PERFORM statement does not end with an END-
PERFORM phrase, it is an out-of-line PERFORM. If the PERFORM statement
ends with an END-PERFORM phrase, it is an in-line PERFORM.
Usage Considerations:
No Execution With TEST BEFORE if the Condition Value is TRUE
If the TEST AFTER phrase is not present and the value of the condition in the
VARYING phrase is TRUE when control first arrives at the PERFORM statement,
the PERFORM range is not executed.
Values of Data Items
The PERFORM VARYING statement initializes and augments the values of one or
more data items in an orderly manner.
When vary-1 or vary-2 is an index-name, it is initialized and subsequently
augmented according to the rules of the SET statement.
When vary-1 or vary-2 is the name of a numeric data item, it is initialized
either according to the rules of the SET statement (if the associated base-1 or
base-2 is an index-name) or according to the rules of the MOVE statement (if
base-1 or base-2 is not an index-name). In either case, subsequent
augmentation (with the BY phrase) occurs in the manner described later.
Execution of PERFORM VARYING with TEST BEFORE Specified or Implied
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. If
condition-1 evaluates to FALSE, the first cycle is performed; if TRUE, no
cycles are performed. After the completion of each cycle, the value of vary-1 is
augmented by step-1, and condition-1 is evaluated again to determine
whether or not to perform another cycle. Whenever the evaluation of
condition-1 results in TRUE, execution of the statement terminates. Figure 9-7
illustrates the execution of a PERFORM VARYING statement with a TEST
BEFORE phrase and without an AFTER phrase list.
After execution of the PERFORM statement terminates, 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.