PERFORM with VARYING Phrase

The VARYING phrase increases or decreases the value of one or more identifiers or index-names, according to certain rules. (See Varying Phrase Rules.)

The Format 4 VARYING phrase PERFORM statement can serially search an entire 7-dimensional table.

PERFORM Statement - Format 4

Read syntax diagramSkip visual syntax diagramPERFORMprocedure-name-1THROUGHTHRUprocedure-name-2phrase 3phrase 3imperative-statement-1END-PERFORM
phrase 3
Read syntax diagramSkip visual syntax diagramWITHTESTBEFOREAFTERVARYINGidentifier-2index-name-1FROMidentifier-3index-name-2literal-1BYidentifier-4literal-2UNTILcondition-1phrase 4
phrase 4
Read syntax diagramSkip visual syntax diagramAFTERidentifier-5index-name-3FROMidentifier-6index-name-4literal-3BYidentifier-7literal-4UNTILcondition-2
condition-1, condition-2
May be any condition described under Conditional Expressions. If the condition is true at the time the PERFORM statement is initiated, the specified procedure(s) are not executed.

After the condition(s) 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. Any subscripting associated with the operands specified in condition-1 is evaluated each time the condition is tested.

If neither the TEST BEFORE nor the TEST AFTER phrase is specified, the TEST BEFORE phrase is assumed.