COBOL/400 Language Help

Format 4 (PERFORM with VARYING)

Description
Format 4 (PERFORM with VARYING) increases or decreases the value of one or more identifiers or index-names according to certain rules for the varying phrase.

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

Format 4 (PERFORM with VARYING)
 
->->---PERFORM-*-procedure-name-1---------------------------> 1
             +
             +
             +
             *-phrase-1 imperative-statement--------------> 2
 
 
1 ->----*----------------------------*-phrase-1--*---------><-
       *-THROUGH-*-procedure-name-2-*           +
       *-THRU----*                              +
                                                +
2 ->----END-PERFORM------------------------------*
 
 
 where phrase-1 is:
 
->->---*------------------------*-VARYING-*-identifier-2-*-->
     *-*------*-TEST-*-BEFORE-*         *-index-name-1-*
       *-WITH-*      *-AFTER--*
 
->---FROM*identifier-3*BY*identifier-4*UNTIL condition-1--->
        *index-name-2*  *literal-2---*
        *literal-1---*
 
->---*-----------------------------------------------------> 3
    + *--------------------------------------------------<- 4
    + V
    *-AFTER-*-identifier-5-*-FROM-*-identifier-6-*-BY-----> 5
            *-index-name-3-*      *-index-name-4-*
                                  *-literal-3----*
 
3 ->----------------------------------------*--------------><-
4 <---------------------------------------* +
                                         + +
5 ->---*-identifier-7-*-UNTIL condition-2-*-*
      *-literal-4----*
 

BEFORE

When you specify TEST BEFORE, all specified conditions are tested before the first execution, and the statements to be performed are executed only when all specified tests fail.

If you do not specify the TEST BEFORE or the TEST AFTER phrase, the TEST BEFORE phrase is assumed.

AFTER

When you specify TEST AFTER, the statements to be performed are executed at least once, before any condition is tested.

If you do not specify the TEST BEFORE or the TEST AFTER phrase, the TEST BEFORE phrase is assumed.

identifier-2, -3, -4, -5, -6, or -7

Identifier-2 thru 7 must name an integer data item.

literal-1, -2, -3, or -4

Literal-1 thru 4 must represent a numeric literal.

condition-1

Condition-1 and condition-2 may be any conditional expression. 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, the subscript is evaluated each time the condition is tested.


[ Top of Page | Previous Page | Next Page | Table of Contents ]