COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
vary-2
is a numeric data item or an index. It is an iteration variable—a variable whose value changes
each time the process executes the code in an inner loop.
base-2
is a numeric literal, an index-name, or the identifier of a numeric data item. It is the initial value
for vary-2.
step-2
is a numeric literal or the identifier of a numeric data item. It is the increment that is to be added
to vary-2 each time control returns from the end of the range of the PERFORM. The value of
step-2 must not be 0.
condition-2
is any conditional expression.
imperative-statement
is defined in Imperative Statement (page 230).
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 18 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.
398 Procedure Division Verbs










