PERFORM with VARYING phrase
The VARYING phrase increases or decreases the value of one or more identifiers or index-names, according to certain rules.
For more information, see Varying phrase rules.
The format-4 VARYING phrase PERFORM statement can serially search an entire seven-dimensional table.
If procedure-name-1 is specified, imperative-statement-1 and the END-PERFORM phrase must not be specified. If procedure-name-1 is omitted, the AFTER phrase must not be specified.
- identifier-2 through identifier-7
- Must name a numeric elementary item. These identifiers cannot be windowed date fields.
- literal-1 through literal-4
- Must represent a numeric literal.
- condition-1, condition-2
- Can be any condition described under Conditional expressions.
If the condition is true at the time the PERFORM statement is initiated,
the specified procedures are not executed.
After the conditions specified in the UNTIL phrase are satisfied, control is passed to the next executable statement following the PERFORM statement.
If any of the operands specified in condition-1 or condition-2 is subscripted, reference modified, or is a function-identifier, the subscript, reference-modifier, or function is evaluated each time the condition is tested.
Floating-point data items and literals can be used anywhere a numeric data item or literal can be specified.
When TEST BEFORE is indicated, all specified conditions are tested before the first execution, and the statements to be performed are executed, if at all, only when all specified tests fail. When TEST AFTER is indicated, the statements to be performed are executed at least once, before any condition is tested.
If neither the TEST BEFORE nor the TEST AFTER phrase is specified, the TEST BEFORE phrase is assumed.