PERFORM with UNTIL phrase
In the UNTIL phrase format, the procedures referred to are performed until the condition specified by the UNTIL phrase is true or for UNTIL EXIT, whenever control is escaped to avoid an infinite loop. For UNTIL with condition-1, control is then passed to the next executable statement following the PERFORM statement.
If procedure-name-1 is specified, imperative-statement-1 and the END-PERFORM phrase must not be specified.
- 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.
Any subscripting associated with the operands specified in condition-1 is evaluated each time the condition is tested.
- If the UNTIL phrase with the EXIT reserved word is specified, execution proceeds exactly as if
the same PERFORM statement were coded with condition-1 specified, except that
condition-1 never evaluates as true.Note: When UNTIL EXIT is specified, ensure that an escape from the PERFORM loop will be reached. For an inline PERFORM statement, this can be done by an EXIT PERFORM (but not EXIT PERFORM CYCLE) statement. For an out-of-line PERFORM statement, this can be done by a GOBACK or STOP statement. Make sure the escape statement used does escape the PERFORM loop. Several statements might appear to do so, but don't actually escape the loop. For example, an EXIT PARAGRAPH (from a performed paragraph) or an EXIT SECTION (from a performed section) do not escape a PERFORM with the UNTIL EXIT phrase.
If the TEST BEFORE phrase is specified or assumed, the condition is tested before any statements are executed (corresponds to DO WHILE).
If the TEST AFTER phrase is specified, the statements to be performed are executed at least once before the condition is tested (corresponds to DO UNTIL).
In either case, if the condition is true, control is transferred to the next executable statement following the end of the PERFORM statement. If neither the TEST BEFORE nor the TEST AFTER phrase is specified, the TEST BEFORE phrase is assumed.
The UNTIL EXIT phrase must not be specified with the TEST BEFORE or TEST AFTER phrase nor with the PERFORM with VARYING phrase.