HP 3000 Manuals

Procedure Division (cont.) [ COBOL/HP-UX Language Reference for the Series 700 and 800 ] MPE/iX 5.0 Documentation


COBOL/HP-UX Language Reference for the Series 700 and 800

Procedure Division (cont.) 

The MOVE Statement 

Function 

The MOVE statement transfers data, in accordance with the rules of
editing, to one or more data areas.

General Formats 

Format 1 

	       Click here to view figure.
            

Format 2 

	       Click here to view figure.
            

Syntax Rules 

   1.  Identifier-1 and literal represent the sending area; identifier-2
       represents the receiving area.
________________________________________________________________________
|(OSVS) (VSC2) (MF)                                                    |
|                                                                      |
|                                                                      |
|                                                                      |
|2.   When Format 1 is specified, all identifiers can be either group  |
|     or elementary items.  The data in the sending area is moved into |
|     the data item referenced by each identifier-2 in the order in    |
|     which it is specified.                                           |
|                                                                      |
________________________________________________________________________

            

3.   CORR is an abbreviation for CORRESPONDING.

4.   When the CORRESPONDING phrase is used, all identifiers must be group
     items.

5.   An index data item or pointer data item or procedure pointer item, 
     (VSC2) (MF) cannot appear as an operand of a MOVE statement.  (See
     the section "The USAGE Clause"  earlier in this chapter.)
________________________________________________________________________
|(VSC2) (MF)                                                           |
|                                                                      |
|                                                                      |
|                                                                      |
|6.   A pointer data item can be part of a group that is referred to in|
|     a MOVE CORRESPONDING statement; however, no movement of the      |
|     pointer data item will take place.                               |
|                                                                      |
|7.   If either the sending or receiving item is a DBCS (USAGE         |
|     DISPLAY-1) item, then both must be DBCS items.  The figurative   |
|     constant SPACE can be the DBCS sending item.                     |
|                                                                      |
________________________________________________________________________

            

General Rules 

   1.  If the CORRESPONDING phrase is used, selected items within
       identifier-1 are moved to selected items within identifier-2,
       according to the rules given in the section "The CORRESPONDING
       Phrase"  earlier in this chapter.  The results are the same as
       if the user had referred to each pair of corresponding identifiers
       in separate MOVE statements.
________________________________________________________________________
|The process is repeated for each destination group.  (VSC2)           |
|(OSVS)                                                                |
________________________________________________________________________

            
________________________________________________________________________
|(MF)                                                                  |
|                                                                      |
|                                                                      |
|                                                                      |
|2.   If identifier-1 is a numeric function-identifier, then           |
|     identifier-2 must be either a numeric or numeric-edited          |
|     item.                                                            |
|                                                                      |
________________________________________________________________________

            

3.   The data designated by the literal or identifier-1 is moved to the
     data item referenced by each identifier-2, in the order in which it
     is specified.  The rules referring to identifier-2 also apply to the
     other receiving areas.  Any subscripting or indexing associated with
     identifier-2, is evaluated immediately before the data is moved to
     the respective data item.
________________________________________________________________________
|(ANS85)                                                               |
|If identifier-1 is reference modified, subscripted, or is a function- |
|identifier, the reference modifier, subscript, or function-identifier |
|is evaluated only once, immediately before data is moved to the first |
|of the receiving operands.                                            |
|                                                                      |
|The result of the statement:                                          |
|                                                                      |
|     MOVE a (b) TO b, c (b)                                           |
|                                                                      |
|is equivalent to:                                                     |
|                                                                      |
|     MOVE a (b) TO temp                                               |
|     MOVE temp TO b                                                   |
|     MOVE temp TO c (b)                                               |
|                                                                      |
|where temp is an intermediate result item provided by your COBOL      |
|system.                                                               |
________________________________________________________________________

            

4.   Any MOVE in which the sending and receiving items are both
     elementary items is an elementary move.  Every elementary
     item belongs to one of the following categories:  numeric,
     alphabetic, alphanumeric, numeric edited, alphanumeric edited  or 
     floating-point.  (OSVS) (VSC2) (MF) These categories are described
     in the PICTURE clause.  Numeric literals belong to the category
     numeric, and nonnumeric literals belong to the category
     alphanumeric.  The figurative constant ZERO belongs to the category
     numeric when moved to a numeric or numeric-edited item.  The
     figurative constant ZERO belongs to the category alphanumeric in all
     other cases.  The figurative constant SPACE belongs to the category
     alphabetic.  All other figurative constants belong to the category
     alphanumeric.

     The following rules apply to an elementary move between these
     categories:

        a.    1)   The figurative constant SPACE, or an alphanumeric
                 edited, or alphabetic data item must not be moved to a
                 numeric or numeric edited data item.
                 [REV BEG]

            2)   A numeric edited data item must not be moved to a
                 numeric or numeric edited data item.[REV END]
________________________________________________________________________
|This restriction is removed.  (ANS85)                                 |
________________________________________________________________________

            

        b.  A numeric literal, the figurative constant ZERO, a numeric
            data item or a numeric edited data item must not be moved to
            an alphabetic data item.

        c.  A non-integer numeric literal or a non-integer numeric
            data item must not be moved to an alphanumeric or
            alphanumeric-edited data item.

        d.  All other elementary moves are legal and are performed
            according to the rules given in General Rule 5.

5.   Any necessary conversion of data from one form of internal
     representation to another takes place during legal elementary moves,
     along with any editing specified for ,or de-editing implied by, 
     (ANS85) the receiving data item:

        a.  When an alphanumeric edited or alphanumeric item is a
            receiving item, alignment and any necessary space filling
            takes place as defined in the section "Standard Alignment
            Rules"  in the chapter COBOL Concepts.  If the size of the
            sending item is greater than the size of the receiving item,
            the excess characters are truncated on the right after the
            receiving item is filled.  If the sending item is described
            as being signed numeric, the operational sign will not be
            moved; if the operational sign occupies a separate character
            position (see the section "The SIGN Clause"  earlier in
            this chapter), that character will not be moved and the size
            of the sending item will be considered to be one less than
            its actual size (in terms of standard data format
            characters).

        b.  When a numeric or numeric edited item is the receiving item,
            alignment by decimal point and any necessary zero-filling
            takes place as defined in the section "Standard Alignment
            Rules"  in the chapter COBOL Concepts, except where zeros
            are replaced because of editing requirements.
________________________________________________________________________
|(ANS85)                                                               |
|[REV BEG]                                                             |
|                                                                      |
|When the sending operand is numeric edited, de-editing is implied to  |
|establish the operand's unedited numeric value, which can be signed;  |
|then the unedited numeric value is moved to the receiving field.      |
|The effect of de-editing depends on the setting of the DE-EDIT        |
|directive (see your COBOL System Reference for details).[REV          |
|END]                                                                  |
________________________________________________________________________

            

            When a signed numeric item is the receiving item, the sign of
            the sending item is placed in the receiving item.  (See the
            section "The SIGN Clause"  earlier in this chapter.)
            Conversion of the representation of the sign takes place as
            necessary.  If the sending item is unsigned, a positive sign
            is generated for the receiving item.

            When an unsigned numeric item is the receiving item, the
            absolute value of the sending item is moved and no
            operational sign is generated for the receiving item.

            When a data item described as alphanumeric is the sending
            item, data is moved as if the sending item were described as
            an unsigned numeric integer.

            When the receiving item is numeric and the sending item is
            defined as alphanumeric, if the content of the sending item
            is not an integer, then results of the move are undefined.
            (See the section "Incompatible Data"  earlier in this
            chapter.)
________________________________________________________________________
|(ANS85)                                                               |
|When the numeric data item is the sending item the action of the move |
|will be such that a reverse of the move would cause the same value to |
|appear in the numeric edited field (except for truncation).  If he    |
|data item contains data which does not conform to the edited picture, |
|zero is moved to the target.                                          |
________________________________________________________________________

            

        c.  When a receiving field is described as alphabetic,
            justification and any necessary space-filling takes place as
            defined in the section "Standard Alignment Rules"  in the
            chapter COBOL Concepts.  If the size of the sending item is
            greater than the size of the receiving item, the excess
            characters are truncated on the right after the receiving
            item is filled.
________________________________________________________________________
|(OSVS) (VSC2) (MF)                                                    |
|                                                                      |
|                                                                      |
|                                                                      |
|d.   When the receiving field is floating-point, the sending item is  |
|     converted first to internal floating-point and then moved.  When |
|     data is moved to or from an external floating-point item, the    |
|     data is converted first to or from its equivalent internal       |
|     floating-point value.                                            |
|                                                                      |
________________________________________________________________________

            
________________________________________________________________________
|(VSC2) (MF)                                                           |
|                                                                      |
|                                                                      |
|                                                                      |
|e.   When the receiving field is DBCS the sending item must           |
|     also be DBCS; no conversion takes place.  If the sending         |
|     and receiving items are not the same size the data item          |
|     will be either truncated or padded with DBCS spaces on the       |
|     right.                                                           |
|                                                                      |
________________________________________________________________________

            

6.   Any move that is not an elementary move is treated exactly as if it
     were an alphanumeric to alphanumeric elementary move, except that
     there is no conversion of data from one form of internal
     representation to another.  In such a move, the receiving area will
     be filled without consideration for the individual elementary or
     group items contained within either the sending or receiving area,
     except as noted in the General Rules of the OCCURS clause.

7.   Table 3-10  summarizes the legality of the various types of MOVE
     statements.  The general rule reference indicates the rule that
     prohibits the move or the behavior of a legal move.

          Table 3-10.  MOVE Statement Data Categories 

	       Click here to view figure.
            

The MULTIPLY Statement 

Function 

The MULTIPLY statement causes numeric data items to be multiplied and
sets the values of data items equal to the results.

General Formats 

Format 1 

	       Click here to view figure.
            

Format 2 

	       Click here to view figure.
            

Syntax Rules 

   1.  Each identifier must refer to a numeric elementary item, except
       that in Format 2 each identifier following the word GIVING must
       refer to either an elementary numeric item or an elementary
       numeric edited item.

   2.  Each literal must be a numeric literal.

   3.  The composite of operands, which is that hypothetical data item
       resulting from the superimposition of all receiving data items
       aligned on their decimal points, must not contain more than 18
       digits.
________________________________________________________________________
|(OSVS) (VSC2) (MF)                                                    |
|                                                                      |
|                                                                      |
|                                                                      |
|4.   Floating-point data items and literals can be used anywhere a    |
|     numeric data item or literal can be specified.                   |
|                                                                      |
________________________________________________________________________

            

General Rules 

   1.  See the sections "The ROUNDED Phrase" , "
       The ON SIZE ERROR Phraseand NOT ON SIZE ERROR Phrase (ANS85)" ,
       "Arithmetic Statements" , "Overlapping Operands"  and
       "Multiple Results in Arithmetic Statements"  in this chapter.

   2.  When Format 1 is used, the value of identifier-1 or literal-1 is
       multiplied by the value of identifier-2.  The value of the
       multiplier (identifier-2) is replaced by this product; similarly
       for each successive occurrence of identifier-2 in the
       left-to-right order in which identifier-2 is specified.

   3.  When Format 2 is used, the value of identifier-1 or literal-1 is
       multiplied by identifier-2 or literal-2 and the result is stored
       in the data item referenced by each identifier-3.
________________________________________________________________________
|he NEXT SENTENCE Statement                                            |
|                                                                      |
|(MF)                                                                  |
|                                                                      |
|Function                                                              |
|                                                                      |
|The NEXT SENTENCE statement transfers control to the next COBOL       |
|sentence, that is, following the next period.  It does not transfer   |
|control to the logically next COBOL verb as occurs with the CONTINUE  |
|verb.                                                                 |
|                                                                      |
|General Format                                                        |
|                                                                      |
|     NEXT SENTENCE                                                    |
|                                                                      |
|Syntax Rule                                                           |
|                                                                      |
|The NEXT SENTENCE statement can be used anywhere a conditional        |
|statement or an imperative-statement can be used.                     |
|                                                                      |
|General Rule                                                          |
|                                                                      |
|The NEXT SENTENCE statement redirects the flow of the program to the  |
|logically next COBOL verb following the next period.                  |
________________________________________________________________________

            
________________________________________________________________________
|The NOTE Statement                                                    |
|                                                                      |
|(OSVS)                                                                |
|                                                                      |
|Function                                                              |
|                                                                      |
|The NOTE statement introduces a sentence or paragraph that will be    |
|treated as comments.                                                  |
|                                                                      |
|General Format                                                        |
|                                                                      |
|     NOTE character-string                                            |
|                                                                      |
|Syntax Rule                                                           |
|                                                                      |
|The character-string can be any combination of characters from the    |
|computer character set.                                               |
|                                                                      |
|General Rules                                                         |
|                                                                      |
|                                                                      |
|   1.  If a NOTE statement is the first sentence of a paragraph, the  |
|       entire paragraph is treated as comment.                        |
|                                                                      |
|   2.  If a NOTE statement appears as other than the first sentence of|
|       a paragraph, text up to the next separator period is treated as|
|       comment.                                                       |
________________________________________________________________________

            
________________________________________________________________________
|The ON Statement                                                      |
|                                                                      |
|(OSVS)                                                                |
|                                                                      |
|Function                                                              |
|                                                                      |
|The ON statement allows selective execution of procedural statements  |
|on a periodic basis.                                                  |
________________________________________________________________________

            

General Format 

	       Click here to view figure.
          (OSVS) 
________________________________________________________________________
|(OSVS)                                                                |
|                                                                      |
|Syntax Rules                                                          |
|                                                                      |
|                                                                      |
|   1.  Identifier-1, identifier-2 and identifier-3 must describe      |
|       unsigned integer numeric elementary items.                     |
|                                                                      |
|   2.  Literal-1, literal-2 and literal-3 must be unsigned numeric    |
|       literals.                                                      |
|                                                                      |
|General Rules                                                         |
|                                                                      |
|                                                                      |
|   1.  Prior to the first execution of each ON statement in           |
|       the program, a counter, implicitly defined for that ON         |
|       statement (the implicit-ON- counter), is initialized to be     |
|       zero.                                                          |
|                                                                      |
|   2.  Identifier-1, identifier-2 and identifier-3 should, if         |
|       specified, contain positive integer values at the time of      |
|       execution of the ON statement.  Varying these values between   |
|       executions of the ON statement will affect subsequent          |
|       executions of the ON statements.                               |
|                                                                      |
|   3.  The implicit ON counter cannot be affected in any way other    |
|       than by transfer of program execution flow to that ON          |
|       statement.  (The ON counter of a called program can only be    |
|       reset by the cancelling of that program; execution of the EXIT |
|       PROGRAM statement and subsequent CALL of the program without   |
|       intervening CANCEL has no effect upon the implicit ON counter  |
|       value.)                                                        |
|                                                                      |
|   4.  The following value-list is then evaluated:                    |
|                                                                      |
|                                                                      |
|          a.  the current value of identifier-1 or literal-1,         |
|                                                                      |
|          b.  a sequence of values being the results of repeatedly    |
|              adding the current value of identifier-2 or literal-2 to|
|              the current value of identifier-1 or literal-1          |
|              until the value of identifier-3 or literal-3 is         |
|              reached.                                                |
|                                                                      |
|       The implicit-ON-counter is then compared with each of this list|
|       of values.  If an equality is found, then imperative-          |
|       statement-1 is executed.  If no equality is found, then        |
|       imperative-statement-2 is executed.                            |
________________________________________________________________________

            

The PERFORM Statement 

Function 

The PERFORM statement is used to transfer control explicitly to one or
more procedures and to return control implicitly whenever execution of
the specified procedure is complete.
________________________________________________________________________
|(ANS85)                                                               |
|The PERFORM statement is also used to control execution of one or more|
|imperative statements which are within the scope of that PERFORM      |
|statement.                                                            |
________________________________________________________________________

            

General Formats 

Format 1 

	       Click here to view figure.
            

Format 2 

	       Click here to view figure.
            

Format 3 

	       Click here to view figure.
            

Format 4 

	       Click here to view figure.
            
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|   1.  If procedure-name-1 is omitted, imperative-statement-1 and the |
|       END-PERFORM phrase must be specified; if procedure-name-1 is   |
|       specified, imperative-statement-1 and the END-PERFORM phrase   |
|       must not be specified.                                         |
|                                                                      |
|       When an imperative-statement-1 is specified, then the          |
|       END-PERFORM phrase is optional.  (MF)                          |
|                                                                      |
|   2.  In Format 4, if procedure-name-1 is omitted, the AFTER phrase  |
|       must not be specified.                                         |
|                                                                      |
|   3.  If neither the TEST BEFORE nor the TEST AFTER phrase is        |
|       specified, the TEST BEFORE phrase is assumed.                  |
________________________________________________________________________

            

4.   Each identifier represents a numeric elementary item described in
     the Data Division.  In Format 2, identifier-1 must be described as a
     numeric integer.

5.   Each literal represents a numeric literal.

6.   The words THROUGH and THRU are equivalent.

7.   If an index-name is specified in the VARYING or AFTER phrase, then:

        a.  The identifier in the associated FROM and BY phrases must
            reference an integer data item.

        b.  The literal in the associated FROM phrase must be a positive
            integer.

        c.  The literal in the associated BY phrase must be a nonzero
            integer.

8.   If an index-name is specified in the FROM phrase, then:

        a.  The identifier in the associated VARYING or AFTER phrase must
            reference an integer data item.

        b.  The identifier in the associated BY phrase must reference an
            integer data item.

        c.  The literal in the associated BY phrase must be an integer.

9.   Literal in the BY phrase must not be zero.

10.  Condition-1, condition-2, ...  , can be any conditional expression.
     (See the section "Conditional Expressions"  earlier in this
     chapter.)

11.  Where procedure-name-1 and procedure-name-2 are both specified and
     either is the name of a procedure in the declaratives portion of the
     Procedure Division, both must be procedure-names in the same
     declarative section.

12.  Two AFTER phrases are permitted in Format 4 of the PERFORM
     statement.
________________________________________________________________________
|(ANS85)                                                               |
|Six AFTER phrases are permitted in Format 4 of the PERFORM statement. |
________________________________________________________________________

            
________________________________________________________________________
|This limit is raised to fifteen.  (MF)                                |
________________________________________________________________________

            
________________________________________________________________________
|(OSVS) (VSC2) (MF)                                                    |
|                                                                      |
|                                                                      |
|                                                                      |
|13.  Floating-point data items and literals can be used anywhere a    |
|     numeric data item or literal can be specified.  They can not be  |
|     used where an integer is required.                               |
|                                                                      |
________________________________________________________________________

            

General Rules 

   1.  The data items referenced by identifier-4 and identifier-7 must
       not have a zero value.

   2.  If an index-name is specified in the VARYING or AFTER phrase, and
       an identifier is specified in the associated FROM phrase, the data
       item referenced by the identifier must have a positive value.

   3.  When procedure-name-1 is specified, the PERFORM statement is
       referred to as an out-of-line PERFORM statement;
________________________________________________________________________
|(ANS85)                                                               |
|when procedure-name-1 is omitted, the PERFORM statement is referred to|
|as an in-line PERFORM statement.                                      |
________________________________________________________________________

            

   4.  The statements contained within the range of procedure-name-1
       (through procedure-name-2 if specified) for an out-of-line PERFORM
       statement
________________________________________________________________________
|(ANS85)                                                               |
|or contained within the PERFORM statement itself for an in-line       |
|PERFORM statement                                                     |
________________________________________________________________________

            

       are referred to as the specified set of statements.
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|5.   The END-PERFORM phrase delimits the scope of the in-line PERFORM |
|     statement.  (See the section "Explicit and Implicit Scope        |
|     Terminators"  in the chapter COBOL Concepts.)                 |
|                                                                      |
|6.   An in-line PERFORM statement functions according to the following|
|     general rules for an otherwise identical out-of-line PERFORM     |
|     statement, with the exception that the statements contained      |
|     within the in-line PERFORM statement are executed in place of the|
|     statements contained within the range of procedure-name-1        |
|     (through procedure-name-2 if specified).  Unless specially       |
|     qualified by the word in-line or out-of-line, all the general    |
|     rules which apply to the out-of-line PERFORM statement also apply|
|     to the in-line PERFORM statement.                                |
|                                                                      |
________________________________________________________________________

            

7.   When the PERFORM statement is executed, control is transferred to
     the first statement of the specified set of statements (except as
     indicated in General Rules 10b, 10c and 10e).  This transfer of
     control occurs only once for each execution of a PERFORM statement.
     For those cases where a transfer of control to the specified set of
     statements does take place, an implicit transfer of control to the
     end of the PERFORM statement is established as follows:

        a.  If procedure-name-1 is a paragraph-name and procedure-name-2
            is not specified, the return is after the last statement of
            procedure-name-1.

        b.  If procedure-name-1 is a section-name and procedure-name-2 is
            not specified, the return is after the last statement of the
            last paragraph in procedure-name-1.

        c.  If procedure-name-2 is specified and it is a paragraph- name,
            the return is after the last statement of the paragraph.

        d.  If procedure-name-2 is specified and it is a section-name,
            the return is after the last statement of the last paragraph
            in the section.
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|e.   If an in-line PERFORM statement is specified, an execution of the|
|     PERFORM statement is completed after the last statement contained|
|     within it has been executed.                                     |
|                                                                      |
________________________________________________________________________

            
________________________________________________________________________
|(MF)                                                                  |
|                                                                      |
|                                                                      |
|                                                                      |
|f.   An EXIT PERFORM statement can be used to exit an in-line         |
|     perform before executing all statements within the in-line       |
|     perform.                                                         |
|                                                                      |
________________________________________________________________________

            

8.   There is no necessary relationship between procedure-name-1 and
     procedure-name-2 except that a consecutive sequence of operations is
     to be executed beginning at the procedure named procedure-name-1 and
     ending with the execution of the procedure named procedure-name-2.
     In particular, GO and PERFORM statements can occur between
     procedure-name-1 and the end of procedure-name-2.  If there are two
     or more logical paths to the return point, then procedure-name-2 can
     be the name of a paragraph consisting of the EXIT statement, to
     which all of these paths must lead.

9.   If control passes to the specified set of statements by means other
     than a PERFORM statement, control will pass through the last
     statement of the set to the next executable statement as if no
     PERFORM statement referenced the set.

10.  The PERFORM statements operate as follows:

        a.  Format 1 is the basic PERFORM statement.  The specified set
            of statements referenced by this type of PERFORM statement is
            executed once and then control passes to the end of the
            PERFORM statement.

        b.  Format 2 is the PERFORM ...  TIMES. The specified set of
            statements is performed the number of times specified by
            integer-1 or by the initial value of the data item referenced
            by identifier-1 for that execution.  If at the time of the
            execution of a PERFORM statement, the value of the data item
            referenced by identifier-1 is equal to zero or is negative,
            control passes to the end of the PERFORM statement.
            Following the execution of the specified set of statements
            the specified number of times, control is transferred to the
            end of the PERFORM statement.

            During execution of the PERFORM statement, reference to
            identifier-1 cannot alter the number of times the specified
            set of statements is to be executed from that which was
            indicated by the initial value of the data item referenced by
            identifier-1.

        c.  Format 3 is the PERFORM ...  UNTIL. The specified set of
            statements is performed until the condition specified by the
            UNTIL phrase is true.  When the condition is true, control is
            transferred to the end of the PERFORM statement.  If the
            condition is true when the PERFORM statement is entered, and 
            the TEST BEFORE phrase is specified or implied, (ANS85) no
            transfer to procedure-name-1 takes place, and control is
            passed to the end of the PERFORM statement.
________________________________________________________________________
|(ANS85)                                                               |
|If the TEST AFTER phrase is specified, the PERFORM statement functions|
|as if the TEST BEFORE phrase were specified except that the condition |
|is tested after the specified set of statements has been executed.    |
|Any subscripting or reference modification associated with the        |
|operands specified in condition-1 is evaluated each time the condition|
|is tested.                                                            |
________________________________________________________________________

            
            [REV BEG]

            When UNTIL EXIT is specified, the specified set of statements
            is performed repeatedly until some statement within the set
            causes this repetition to end.  In the case of an out-of-line
            PERFORM, the only statements that will cause this termination
            are statements such as EXIT PROGRAM and STOP RUN. In the case
            of an in-line PERFORM, the repetition can also be terminated
            by the EXIT PERFORM statement and the GO TO statement.[REV
            END]

     d.   Format 4 is the PERFORM ...  VARYING. This variation of the
          PERFORM statement is used to augment the values referenced by
          one or more identifiers or index-names in an orderly fashion
          during the execution of a PERFORM statement.  In the following
          discussion, every reference to identifier as the object of the
          VARYING, AFTER, and FROM (current value) phrases also refers to
          index-names.

          If index-name-1 is specified, the value of identifier-3,
          index-name-2, or literal-1 at the beginning of the execution of
          the PERFORM statement must correspond to an occurrence number
          of an element in the table associated with index-name-1.  If
          index-name-3 is specified, the value of identifier-6,
          index-name-4, or literal-3 at the beginning of the execution of
          the PERFORM statement must correspond to an occurrence number
          of an element in the table associated with index-name-3.

          Subsequent augmentation, as described below, of index-name-1 or
          index-name-3 must not result in the associated index being set
          to a value outside the range of the table associated with
          index-name-1 or index-name-3; except that, at the completion of
          the PERFORM statement, the index associated with index-name-1
          can contain a value that is outside the range of the associated
          table by one increment or decrement value.

          If identifier-2 or identifier-5 is subscripted, the subscripts
          are evaluated each time the content of the data item referenced
          by the identifier is set or augmented.  If identifier-3,
          identifier-4, identifier-6, or identifier-7 is subscripted, the
          subscripts are evaluated each time the content of the data item
          referenced by the identifier is used in a setting or augmenting
          operation.  Any subscripting or reference modification
          associated with the operands specified in condition-1 or
          condition-2 is evaluated each time the condition is tested.

          Representations of the actions of several types of Format 5
          PERFORM statements are given on the following pages.

             1.  If the TEST BEFORE phrase is specified or implied:

                 When the data item referenced by one identifier is
                 varied, the content of the data item referenced by
                 identifier-2 is set to literal-1 or the current value of
                 the data item referenced by identifier-3 at the point of
                 initial execution of the PERFORM statement; then, if the
                 condition of the UNTIL phrase is false, the specified
                 set of statements is executed once.  The value of the
                 data item referenced by identifier-2 is augmented by the
                 specified increment or decrement value (literal-2 or the
                 value of the data item referenced by identifier-4) and
                 condition-1 is evaluated again.  The cycle continues
                 until this condition is true, at which point control is
                 transferred to the end of the PERFORM statement.  If
                 condition-1 is true at the beginning of execution of the
                 PERFORM statement, control is transferred to the end of
                 the PERFORM statement.

	       Click here to view figure.
          Figure 3-1.  The VARYING Option of a PERFORM Statement with the 
                       TEST BEFORE Phrase Having One Condition 
                 When the data items referenced by two identifiers are
                 varied, the content of the data item referenced by
                 identifier-2 is set to literal-1 or the current value of
                 the data item referenced by identifier-3 and then the
                 content of the data item referenced by identifier-5 is
                 set to literal-3 or the current value of the data item
                 referenced by identifier-6.  After the contents of the
                 data items referenced by the identifiers have been set,
                 condition-1 is evaluated; if true, control is
                 transferred to the end of the PERFORM statement; if
                 false, condition-2 is evaluated.  If condition-2 is
                 false, the specified set of statements is executed once,
                 then the content of the data item referenced by
                 identifier-5 is augmented by literal-4 or the content of
                 the data item referenced by identifier-7 and condition-2
                 is evaluated again.  This cycle of evaluation and
                 augmentation continues until this condition is true.
                 When condition-2 is true, the content of the data item
                 referenced by identifier-2 is augmented by literal-2 or
                 the content of the data item referenced by identifier-4,
                 the content of the data item referenced by identifier-5
                 is set to literal-3 or the current value of the data
                 item referenced by identifier-6, and condition-1 is
                 reevaluated.  The PERFORM statement is completed if
                 condition-1 is true; if not, the cycle continues until
                 condition-1 is true.

	       Click here to view figure.
          Figure 3-2.  The VARYING Option of a PERFORM Statement with the 
                       TEST BEFORE Phrase Having Two Conditions 
                 At the termination of the PERFORM statement, the data
                 item referenced by identifier-5 contains literal-3 or
                 the current value of the data item referenced by
                 identifier-6.  The data item referenced by identifier-2
                 contains a value that exceeds the last used setting by
                 one increment or decrement value, unless condition-1 was
                 true when the PERFORM statement was entered, in which
                 case the data item referenced by identifier-2 contains
                 literal-1 or the current value of the data item
                 referenced by identifier-3.
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|2.   If the TEST AFTER phrase is specified:                           |
|                                                                      |
|     When the data item referenced by one identifier is varied, the   |
|     content of the data item referenced by identifier-2 is           |
|     set to literal-1 or the current value of the data item           |
|     referenced by identifier-3 at the point of execution of the      |
|     PERFORM statement; then the specified set of statements          |
|     is executed once and condition-1 of the UNTIL phrase is          |
|     tested.  If the condition is false, the value of the data item   |
|     referenced by identifier-2 is augmented by the specified         |
|     increment or decrement value (literal-2 or the value of the      |
|     data item referenced by identifier-4) and the specified          |
|     set of statements is executed again.  The cycle continues        |
|     until condition-1 is tested and found to be true, at which       |
|     point control is transferred to the end of the PERFORM           |
|     statement.                                                       |
|                                                                      |
________________________________________________________________________

            

	       Click here to view figure.
          Figure 3-3.  The VARYING Option of a PERFORM Statement with 
                       the TEST AFTER Phrase Having One Condition 
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|     When the data items referenced by two identifiers are varied, the|
|     content of the data item referenced by identifier-2 is set to    |
|     literal-1 or the current value of the data item referenced by    |
|     identifier-3; then the current value of the data item referenced |
|     by identifier-5 is set to literal-3 or the current value of the  |
|     data item referenced by identifier-6; and the specified          |
|     set of statements is then executed.  Condition-2 is then         |
|     evaluated; if false, the content of the data item referenced by  |
|     identifier-5 is augmented by literal-4 or the content of the data|
|     item referenced by identifier-7 and the specified set of         |
|     statements is again executed.  The cycle continues until         |
|     condition-2 is again evaluated and found to be true, at          |
|     which time condition-1 is evaluated.  If false, the content      |
|     of the data item referenced by identifier-2 is augmented         |
|     by literal-2 or the content of data item referenced by           |
|     identifier-4, the content of the data item referenced by         |
|     identifier-5 is set to literal-3 or the current value of the data|
|     item referenced by identifier-6 and the specified set of         |
|     statements is again executed.  This cycle continues until        |
|     condition-1 is again evaluated and found to be true, at          |
|     which time control is transferred to the end of the PERFORM      |
|     statement.                                                       |
|                                                                      |
|     After completion of the PERFORM statement, each data item varied |
|     by an AFTER or VARYING phrase contains the same value it         |
|     contained at the end of the most recent execution of the         |
|     specified set of statements.  See Figure 3-4 .                |
|                                                                      |
________________________________________________________________________

            

	       Click here to view figure.
          Figure 3-4.    
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|     During the execution of the specified set of statements          |
|     associated with the PERFORM statement, any change to the VARYING |
|     variable (the data item referenced by identifier-2 and           |
|     index-name-1), the BY variable (the data item referenced by      |
|     identifier-4), the AFTER variable (the data item referenced by   |
|     identifier-5 and index-name-3), or the FROM variable (the data   |
|     item referenced by identifier-3 and index-name-2) will be taken  |
|     into consideration and will affect the operation of the PERFORM  |
|     statement.                                                       |
|                                                                      |
|     When the data items referenced by two identifiers are varied,    |
|     the data item referenced by identifier-5 goes through a          |
|     complete cycle (FROM, BY, UNTIL) each time the content of        |
|     the data item referenced by identifier-2 is varied.  When        |
|     the contents of three or more data items referenced by           |
|     identifiers are varied, the mechanism is the same as for two     |
|     identifiers except that the data item being varied by each       |
|     AFTER phrase goes through a complete cycle each time the         |
|     data item being varied by the preceding AFTER phrase is          |
|     augmented.                                                       |
|                                                                      |
________________________________________________________________________

            

11.  The range of a PERFORM statement consists logically of all those
     statements that are executed as a result of executing the PERFORM
     statement through execution of the explicit transfer of control to
     the end of the PERFORM statement.  The range includes all statements
     that are executed as the result of a transfer of control by CALL,
     EXIT, GO TO and PERFORM statements in the range of the PERFORM
     statement, as well as all statements in declarative procedures that
     are executed as a result of the execution of statements in the range
     of the PERFORM statement.  The statements in the range of a PERFORM
     statement need not appear consecutively in the source program.

12.  Statements executed as the result of a transfer of control caused by
     executing an EXIT PROGRAM statement within the range of a PERFORM
     statement are not considered to be part of that range.

13.  If the range of a PERFORM statement includes another PERFORM
     statement, the sequence of procedures associated with the included
     PERFORM should itself either be totally included in, or totally
     excluded from, the logical sequence referred to by the first
     PERFORM. Thus, an active PERFORM statement, whose execution point
     begins within the range of another active PERFORM statement should
     not allow control to pass to the exit of the other active PERFORM
     statement; furthermore, two or more such active PERFORM statements
     should not have a common exit.
________________________________________________________________________
|(MF)                                                                  |
|These restrictions are not enforced.  PERFORM statements can be freely|
|nested, and recursion (a PERFORM statement performing a procedure     |
|containing it) is allowed.  Only the exit point of the innermost      |
|PERFORM statement currently being executed is recognized.  These rules|
|can be changed by use of the PERFORM-TYPE directive (see your COBOL   |
|System Reference).                                                    |
________________________________________________________________________

            

See the following illustrations for examples of legal PERFORM constructs.

	       Click here to view figure.
            

14.  A PERFORM statement that appears in a section that is not in an
     independent segment can have within its range, in addition to any
     declarative sections whose execution is caused within that range,
     one of the following:

        a.  Sections and/or paragraphs wholly contained in one or more
            non-independent segments.

        b.  Sections and/or paragraphs wholly contained in a single
            independent segment.
________________________________________________________________________
|These restrictions do not apply.  (OSVS) (VSC2)                       |
________________________________________________________________________

            

15.  A PERFORM statement that appears in an independent segment can have
     within its range, in addition to any declarative sections whose
     execution is caused within that range, only one of the following:

        a.  Sections and/or paragraphs wholly contained in one or more
            non-independent segments.

        b.  Sections and/or paragraphs wholly contained in the same
            independent segment as that PERFORM statement.
________________________________________________________________________
|These restrictions do not apply.  (OSVS) (VSC2)                       |
________________________________________________________________________

            



MPE/iX 5.0 Documentation