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 ALTER Statement 
Function 
The ALTER statement modifies a predetermined sequence of operations.
________________________________________________________________________
|(ANS85)                                                               |
|The ALTER statement is classed as an obsolete element in the ANSI'85  |
|standard and is scheduled to be deleted from the next full revision of|
|the ANSI Standard.                                                    |
________________________________________________________________________
            
________________________________________________________________________
|(MF)                                                                  |
|All dialects within this COBOL implementation fully support this      |
|syntax.  Refer to your COBOL System Reference for details on          |
|using the FLAGSTD directive to detect all occurrences of this         |
|syntax.                                                               |
________________________________________________________________________
            
________________________________________________________________________
|(XOPEN)                                                               |
|Although it is a part of the standard COBOL definition, this verb is  |
|explicitly excluded from the X/Open COBOL language definitions        |
|and should not be used in an X/Open COBOL conforming source           |
|program.                                                              |
________________________________________________________________________
            
General Format 
     ALTER procedure-name-1 TO [PROCEED TO]  procedure-name-2
         [ procedure-name-3 TO [PROCEED TO] procedure-name-4] ...
Syntax Rules 
   1.  Each procedure-name-1, procedure-name-3, ..., is the name of a
       paragraph that contains a single sentence consisting of a GO TO
       statement without the DEPENDING phrase.
   2.  Each procedure-name-2, procedure-name-4, ..., is the name of a
       paragraph or section in the Procedure Division.
General Rules 
   1.  Execution of the ALTER statement modifies the GO TO statement in
       the paragraph named procedure-name-1, procedure-name-3, ..., so
       that subsequent executions of the modified GO TO statements cause
       transfer of control to procedure-name-2, procedure-name-4, ...,
       respectively.  Modified GO TO statements in independent segments
       can, under some circumstances, be returned to their initial
       states (see the section Independent Segments in the chapter
       Segmentation).
   2.  A GO TO statement in a section whose segment-number is greater
       than or equal to 50 must not be referred to by an ALTER statement
       in a section with a different segment- number.
       All other uses of the ALTER statement are valid and are performed
       even if procedure-name-1, procedure-name-3 is in an overlayable
       fixed segment.
The CALL Statement.   
Function 
The CALL statement causes control to be transferred from one object
program to another within the run unit.
________________________________________________________________________
|(MF)                                                                  |
|You may CALL the target object program procedure indirectly, by       |
|address.  Data, pointers to data, and pointers to procedures can be   |
|passed as parameters to the called program procedure, and returned by |
|it.  Parameter passing conventions can be controlled in order to      |
|allow the called program procedure to be written in languages         |
|other than COBOL, using different conventions.  A called COBOL        |
|program can recursively call itself when a Local-Storage Section      |
|exists.                                                               |
________________________________________________________________________
            
General Format 
Format 
            
Syntax Rules 
   1.  Identifier-1 must be defined as an alphanumeric data item.
   2.  Literal-1 must be a nonnumeric literal.
   3.  The USING phrase is included in the CALL statement only if there
       is a USING phrase in the PROCEDURE DIVISION header of the called
       program or the referenced ENTRY USING statement.  (OSVS) (VSC2)
       (MF) The number of operands in the two USING phrases should be the
       same.
________________________________________________________________________
|(OSVS) (VSC2) (MF)                                                    |
|This rule is not enforced (see the section "Procedure Division"    |
|earlier in this chapter).                                             |
________________________________________________________________________
            
   4.  Each of the operands in the USING phrase must have been defined as
       a data item in the File Section, Working-Storage Section,
       Communication Section or Linkage Section, and must have a
       level-number of 01 or 77 or 02 through 49.  (ANS85)
   5.  Identifier-1, identifier-2, ..., may be qualified when they
       reference data items defined in the File Section or the
       Communication Section.
________________________________________________________________________
|(VSC2) (MF)                                                           |
|                                                                      |
|                                                                      |
|                                                                      |
|6.   The BY REFERENCE phrase can be a floating-point data item.       |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(VSC2)                                                                |
|                                                                      |
|                                                                      |
|                                                                      |
|7.   Record-name must be the name of an 01 or 77 level item in the    |
|     Linkage Section.                                                 |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(MF)                                                                  |
|                                                                      |
|                                                                      |
|                                                                      |
|8.   Record-name can be any level data item in either Linkage Section |
|     or Working-Storage Section.  If it is a non-01 level in Linkage  |
|     Section or it is any level in Working-Storage Section, it is     |
|     equivalent to passing the item BY CONTENT and it cannot be       |
|     modified by the called subprogram.                               |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(OSVS) (VSC2) (MF)                                                    |
|                                                                      |
|                                                                      |
|                                                                      |
|9.   Identifier-2 can be a floating point data item.                  |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(VSC2) (MF)                                                           |
|                                                                      |
|                                                                      |
|                                                                      |
|10.  Literal-2 must be non-numeric and cannot be a figurative         |
|     constant.                                                        |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(VSC2) (OSVS) (MF)                                                    |
|                                                                      |
|                                                                      |
|                                                                      |
|11.  Conversions to the value specified in literal-1 and to the       |
|     value stored in identifier-1 are sensitive to the MAPNAME        |
|     and CASE directives.  See your COBOL System Reference for        |
|     details.                                                         |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|12.  Identifier-2 must not be a function-identifier.                  |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(MF)                                                                  |
|                                                                      |
|Format 3                                                              |
|                                                                      |
|                                                                      |
|                                                                      |
|13.  Mnemonic-name must be defined in the SPECIAL-NAMES paragraph to  |
|     define the parameter passing convention to be used by this CALL  |
|     to a subprogram.  See the section "The Special-Names Paragraph"  |
|      earlier in this chapter for details.                         |
|                                                                      |
|14.  If the mnemonic-name phrase is omitted, CALL-CONVENTION 0 is     |
|     assumed.  See your COBOL System Reference for details.           |
|                                                                      |
|15.  Procedure-pointer-data-item-1 must reference a procedure         |
|     pointer SET to an entry-point which is either the PROCEDURE      |
|     DIVISION header, or an ENTRY statement, or a label in another    |
|     language.                                                        |
|                                                                      |
|16.  The SIZE clause defines the size of the value to pass in         |
|     bytes.                                                           |
|                                                                      |
|17.  If the SIZE clause is present, literal-2 must be numeric and it  |
|     is passed in COMP-5 format.                                      |
|                                                                      |
|18.  Identifier-3 must be defined as a data item in the Linkage       |
|     Section with a level number of 01.                               |
|                                                                      |
________________________________________________________________________
            
General Rules 
   1.  The execution of a CALL statement causes control to pass to the
       called program.
________________________________________________________________________
|(MF)                                                                  |
|                                                                      |
|                                                                      |
|                                                                      |
|2.   If literal-1 or the data referenced by identifier-1 consists     |
|     entirely of numeric digits or a single non-ASCII character, then |
|     the program which is identified is known as a called-run-time    |
|     subrbroutine.  Such programs are always in "last used" state when|
|     called a second or subsequent time.                              |
|                                                                      |
|     Whether a subprogram is accessed in last-used or initial-state is|
|     sensitive to the DYNAM directive.  See your COBOL System         |
|     Reference for details.                                           |
|                                                                      |
________________________________________________________________________
            
3.   If literal-1 or the data referenced by identifier-1 contains a value
     other than as in general rule 2 above, then the program which is
     identified is a COBOL subprogram.  Such a program is entered in
     initial-state the first time it is called within a run-unit and the
     first time it is called after a CANCEL of the called program.
     On all other entries into the called program, the state of the
     program remains unchanged from its state when last exited.  This
     includes all data fields, the status and positioning of all files,
     and all alterable switch settings.
4.   After control is returned from the called program, the ON OVERFLOW
     or ON EXCEPTION phrase, if specified, (ANS85) is ignored and control
     is transferred to the end of the CALL statement
________________________________________________________________________
|(ANS85)                                                               |
|or, if the NOT ON EXCEPTION phrase is specified, to imperative-       |
|statement-2.  If control is transferred to imperative-statement-2,    |
|execution continues according to the rules for each statement         |
|specified in imperative-statement-2.  If a procedure branching or     |
|conditional statement which causes explicit transfer of control is    |
|executed, control is transferred in accordance with the rules for     |
|that statement; otherwise, upon completion of the execution of        |
|imperative-statement-2, control is transferred to the end of the CALL |
|statement.                                                            |
________________________________________________________________________
            
5.   If during the execution of a CALL statement, it is determined that
     the available portion of run-time memory is incapable of
     accommodating the program specified in the CALL statement, the next
     sequential instruction is executed.  If ON OVERFLOW or ON EXCEPTION 
     (ANS85) has been specified, the associated imperative statement is
     executed and the NOT ON EXCEPTION phrase, if specified, is ignored. 
     (ANS85)
________________________________________________________________________
|(OSVS)                                                                |
|ON OVERFLOW and ON EXCEPTION are treated as identical.  They cause a  |
|check that there is enough memory and a check that the called         |
|subprogram can be made available.                                     |
|                                                                      |
|When the ON OVERFLOW phrase is specified and the OSVS directive is    |
|set, only the check for enough memory is made.                        |
________________________________________________________________________
            
6.   The parameters specified by the USING phrase of the CALL statement
     indicate those data items available to a calling program that can be
     referred to in the called program.  The order of appearance of the
     parameters in the USING phrase of the CALL statement and the USING
     phrase in the PROCEDURE DIVISION header is critical.  Corresponding
     parameters refer to a single set of data which is available to the
     called and calling program.  The correspondence is positional, not
     by name.  In the case of index-names, no such correspondence is
     established.  Index-names in the called and calling program always
     refer to separate indices.
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|7.   Two or more programs in the run unit can have the same           |
|     program-name, and the reference in a CALL statement to such a    |
|     program-name is resolved by using the scope of names conventions |
|     for program-names.  See the section Conventions For Program-Names|
|     in the chapter COBOL Concepts.                                   |
|                                                                      |
|     For example, when two programs in the run unit have the same name|
|     as that specified in a CALL statement:                           |
|                                                                      |
|                                                                      |
|        a.  One of those two programs must also be contained directly |
|            or indirectly either within the separate program which    |
|            includes that CALL statement or within the separate       |
|            program which itself directly or indirectly contains      |
|            the program which includes that CALL statement,           |
|            and                                                       |
|                                                                      |
|        b.  The other of those two programs must be a different       |
|            separate program.                                         |
|                                                                      |
|     The mechanism used in this example is as follows:                |
|                                                                      |
|                                                                      |
|        a.  If one of the two programs having the same name as that   |
|            specified in the CALL statement is directly contained     |
|            within the program which includes that CALL statement,    |
|            that program is called.                                   |
|                                                                      |
|        b.  If one of the two programs having the same name as that   |
|            specified in the CALL statement possesses the common      |
|            attribute and is directly contained within another program|
|            which directly or indirectly contains the program which   |
|            includes the CALL statement, that common program is called|
|            unless the calling program is contained within that common|
|            program.                                                  |
|                                                                      |
|        c.  Otherwise, the separate program is called.                |
|                                                                      |
|8.   If the called program does not possess the initial attribute, it,|
|     and each program directly or indirectly contained within it, is  |
|     in its initial state the first time it is called within a run    |
|     unit and the first time it is called after a CANCEL operation to |
|     the called program.                                              |
|                                                                      |
|     On all other entries into the called program, the state          |
|     of the program and each program directly or indirectly           |
|     contained within it remains unchanged from its state when last   |
|     exited.                                                          |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|9.   If the called program possesses the initial attribute, it and    |
|     each program directly or indirectly contained within it, is      |
|     placed into its initial state every time the called program is   |
|     called within a run unit.                                        |
|                                                                      |
|10.  Files associated with a called program's internal file connectors|
|     are not in the open mode when the program is in an initial state.|
|     See the section "Initial State of a Program"  earlier in this |
|     chapter.                                                         |
|                                                                      |
|     On all other entries into the called program, the states and     |
|     positioning of all such files is the same as when the called     |
|     program was last exited.                                         |
|                                                                      |
|11.  The process of calling a program or exiting from a called program|
|     does not alter the status or positioning of a file associated    |
|     with any external file connecter.                                |
|                                                                      |
|12.  The values of the parameters referenced in the USING phrase of   |
|     the CALL statement are made available to the called program at   |
|     the time the CALL statement is executed.                         |
|                                                                      |
________________________________________________________________________
            
13.  The CALL statement can appear anywhere within a segmented program.
     Therefore, when a CALL statement appears in a section with a
     segment-number greater than or equal to 50, that segment is in its
     last used state when the EXIT PROGRAM statement returns control to
     the calling program.
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|14.  The BY CONTENT, BY REFERENCE and BY VALUE (MF) phrases are       |
|     transitive across the parameters which follow them until         |
|     another BY CONTENT, BY REFERENCE or BY VALUE (MF) phrase is      |
|     encountered.                                                     |
|                                                                      |
|     If no BY CONTENT, BY REFERENCE or BY VALUE (MF) phrase is        |
|     specified prior to the first parameter, the BY REFERENCE phrase  |
|     is assumed.  (However, see General Rule 21 later for additional  |
|     information.)                                                    |
|                                                                      |
________________________________________________________________________
            
15.  If the BY REFERENCE phrase is either specified or (ANS85) implied
     for a parameter, the object program operates as if the corresponding
     data item in the called program occupies the same storage area as
     the data item in the calling program.  The description of the data
     item in the called program must describe the same number of
     character positions as described by the description of the
     corresponding data item in the calling program.
________________________________________________________________________
|(VSC2) (MF)                                                           |
|If BY REFERENCE ADDRESS OF record-name is specified in a USING        |
|phrase, the value passed to the called program is the address         |
|of the record.  The corresponding item in the USING phrase of         |
|the called program's PROCEDURE DIVISION header must have USAGE        |
|POINTER.                                                              |
________________________________________________________________________
            
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|16.  If the BY CONTENT phrase is specified or implied for a parameter,|
|     the called program cannot change the value of this parameter as  |
|     referenced in the CALL statement's USING phrase, though the      |
|     called program can change the value of the data item referenced  |
|     by the corresponding data-name in the called program's           |
|     PROCEDURE DIVISION header.  The data description of each         |
|     parameter in the BY CONTENT phrase of the CALL statement         |
|     must be the same, meaning no conversion or extension or          |
|     truncation, as the data description of the corresponding         |
|     parameter in the USING phrase of the PROCEDURE DIVISION          |
|     header.                                                          |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(VSC2) (MF)                                                           |
|If literal-2 is specified, then its length must be the same as that of|
|the corresponding parameter in the USING phrase of the PROCEDURE      |
|DIVISION header.                                                      |
|If LENGTH of identifier-3 is specified, then the corresponding        |
|parameter in the USING phrase of the PROCEDURE DIVISION header should |
|be defined as PIC 9(9) USAGE IS BINARY.                               |
________________________________________________________________________
            
________________________________________________________________________
|(XOPEN) (MF)                                                          |
|                                                                      |
|                                                                      |
|                                                                      |
|17.  If the BY VALUE phrase is specified or implied for a parameter,  |
|     the called program cannot change the value of this parameter in  |
|     the calling program.  Only the value of the parameter is passed  |
|     to the called program; the address of the parameter is not       |
|     passed.  The BY VALUE phrase is intended for use in calling      |
|     programs in other languages; it should not be used in calling a  |
|     COBOL program.  See your COBOL System Reference for details      |
|     of the format the value takes when it is passed to your          |
|     system.                                                          |
|                                                                      |
________________________________________________________________________
            
18.  Called programs can contain CALL statements.  However, a called
     program must not execute a CALL statement that directly or
     indirectly calls the calling program.  If a CALL statement is
     executed within the range of a declarative, that CALL statement
     cannot directly or indirectly reference any called program to which
     control has been transferred and which has not completed execution.
________________________________________________________________________
|(MF)                                                                  |
|A called program can directly or indirectly call a program that calls |
|the calling program, that is, recursion is supported.  However,       |
|this support is only available when a Local-Storage Section is        |
|present.                                                              |
________________________________________________________________________
            
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|19.  The END-CALL phrase delimits the scope of the CALL statement.    |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(MF)                                                                  |
|                                                                      |
|                                                                      |
|                                                                      |
|20.  On a system where object programs can be kept in libraries for   |
|     calling dynamically (see your COBOL System Reference),           |
|     identifier-1 or literal-1 can specify the name of such a library.|
|     This CALL statement opens the library, that is, adds it to the   |
|     list of libraries that future CALL statements in the run-unit    |
|     will search when looking for a program.                          |
|                                                                      |
|21.  If a literal is used in a phrase that would otherwise be         |
|     considered to be a BY REFERENCE phrase, then it is implicitly    |
|     treated as a BY CONTENT phrase.  However, this applies           |
|     only to this single parameter and is not transitive across       |
|     parameters.                                                      |
|                                                                      |
|22.  If literal-1 or the value in identifier-1 includes an extension, |
|     for example "ABC.gnt", or a path name such as "d:\xyz\ABC" on    |
|     DOS, or "/xyz/ABC" on UNIX, then the results of the CALL         |
|     statement are operating system specific.  In many operating      |
|     systems this will actually cause any currently called program    |
|     "ABC" which is already available in memory to be called again.   |
|     This is true even if the version currently in memory was         |
|     originally called with a different extension, such as "ABC.int"  |
|     or a different path such as "c:\lmn\ABC" on DOS, or "/lmn/ABC" on|
|     UNIX, or both.  See your COBOL System Reference for the rules in |
|     your environment.                                                |
|                                                                      |
|                                                                      |
|Format 3                                                              |
|                                                                      |
|                                                                      |
|                                                                      |
|23.  It is not possible to CANCEL a procedure pointer.  A procedure   |
|     pointer can be removed only by cancelling the program in which it|
|     is contained.                                                    |
|                                                                      |
|24.  Subsequent CALLs to a procedure pointer will produce             |
|     unpredictable results.  On some systems it can cause a protection|
|     violation.                                                       |
|                                                                      |
|25.  The size of GIVING and VALUE fields is limited to four bytes.    |
|     Specific operating systems or COBOL implementations can have     |
|     different limits.  See your COBOL System Reference for additional|
|     information.                                                     |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(MF)                                                                  |
|                                                                      |
|                                                                      |
|                                                                      |
|26.  For a system in which COMP-5 fields are stored in "reverse order"|
|     an implicit (invisible to the program/programmer) move will occur|
|     if the VALUE field is defined as BINARY, COMP, COMP-4, or        |
|     COMP-X                                                           |
|                                                                      |
|                                                                      |
|        a.  From an implicit COMP-5 item to a receiving binary        |
|            field upon program entry when a BY VALUE phrase is        |
|            specified in either a PROCEDURE USING or ENTRY USING      |
|            statement.                                                |
|                                                                      |
|        b.  From an implicit COMP-5 item to a receiving binary field  |
|            upon completion of a CALL GIVING statement                |
|                                                                      |
|        c.  From an implicit COMP-5 item to a receiving binary        |
|            field upon program entry when a BY VALUE phrase is        |
|            specified in either a PROCEDURE USING or ENTRY USING      |
|            statement.                                                |
|                                                                      |
|27.  GIVING items are not affected by the RTNCODE-SIZE directive.     |
|                                                                      |
|28.  If the RETURN-CODE special register is used either as the CALL   |
|     GIVING field or in an EXIT PROGRAM, STOP RUN, or GOBACK GIVING,  |
|     but not both, then the receiving field will be in reverse        |
|     order (in systems which store COMP-5 fields in reverse           |
|     order).                                                          |
|                                                                      |
|29.  It is the programmer's responsibility to ensure that fields      |
|     referenced in a BY VALUE phrase agree as to size and USAGE in    |
|     both the calling and called program.  In cases where these rules |
|     are violated, results are unpredictable.  However, there will be |
|     no compile-time verification of this.                            |
|                                                                      |
|     In cases such as COMP-5 and Pointer data items where, in         |
|     some COBOL systems, they are implicitly identical storage        |
|     definitions in the current implementation, mixing these different|
|     USAGEs in the CALLing and CALLed programs can give the           |
|     desired results today, but upward compatibility is not           |
|     guaranteed.                                                      |
|                                                                      |
|30.  If no value is returned by the called program the contents of    |
|     identifier-2 are unpredictable.                                  |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(MF)                                                                  |
|                                                                      |
|Example                                                               |
|                                                                      |
|Calling program:                                                      |
|                                                                      |
|     01 startpoint procedure-pointer.                                 |
|                .                                                     |
|     procedure division.                                              |
|                .                                                     |
|                .                                                     |
|             set startpoint to entry "Joe"                            |
|             call "controller" using startpoint.                      |
|                .                                                     |
|                .                                                     |
|                                                                      |
|     entry "Fred".                                                    |
|                .                                                     |
|                .                                                     |
|                                                                      |
|Called program (controller):                                          |
|                                                                      |
|     linkage section.                                                 |
|             01 current-proc usage is                                 |
|                procedure-pointer.                                    |
|             procedure division using current-proc.                   |
|                call current-proc.                                    |
|                                                                      |
|Entry-point is in a third program:                                    |
|                                                                      |
|     procedure division.                                              |
|                .                                                     |
|                .                                                     |
|             entry "Joe".                                             |
|                .                                                     |
|                .                                                     |
________________________________________________________________________
            
The CANCEL Statement.   
Function 
The CANCEL statement ensures that the next time the referenced program is
called it will be in its initial state.
General Format 
            
Syntax Rules 
   1.  Literal-1 must be a nonnumeric literal.
   2.  Identifier-1 must reference an alphanumeric data item.
General Rules 
   1.  Literal-1 or the content of the data item referenced by
       identifier-1 identifies the program to be cancelled.
   2.  Subsequent to the execution of an explicit or implicit CANCEL
       statement, the program referred to therein ceases to have any
       logical relationship to the run unit in which the CANCEL statement
       appears.  If the program referenced by a successfully executed
       explicit or implicit CANCEL statement in a run unit is
       subsequently called in that run unit, that program is in its
       initial state.  See the section "Initial State of a Program"  
       earlier in this chapter.
   3.  A program named in a CANCEL statement in another program must be
       callable by that other program.  See the sections Scope Of Names 
       and "The CALL Statement" , earlier in this chapter.
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|4.   When an explicit or implicit CANCEL statement is executed, all   |
|     programs contained within the program referenced by the CANCEL   |
|     statement are also cancelled.  The result is the same as if a    |
|     valid CANCEL statement were executed for each contained program  |
|     in the reverse order in which the programs appear in the separate|
|     program.                                                         |
|                                                                      |
________________________________________________________________________
            
5.   A program named in the CANCEL statement must not refer directly or
     indirectly to any program that has been called and has not yet
     executed an EXIT PROGRAM  or GOBACK (OSVS) (VSC2) (MF) statement.
6.   A logical relationship to a cancelled program is established only by
     execution of a subsequent CALL statement naming that program.
7.   A called program is cancelled either by being referred to as the
     operand of a CANCEL statement, by the termination of the run unit of
     which the program is a member,
________________________________________________________________________
|(ANS85)                                                               |
|or by execution of an EXIT PROGRAM statement in a called program that |
|possesses the initial attribute.                                      |
________________________________________________________________________
            
8.   No action is taken when an explicit or implicit CANCEL statement is
     executed naming a program that has not been called in this run unit
     or has been called and is at present cancelled.  Control is
     transferred to the next executable statement following the CANCEL
     statement.
________________________________________________________________________
|(ANS85)                                                               |
|                                                                      |
|                                                                      |
|                                                                      |
|9.   The contents of data items in external data records described by |
|     a program are not changed when that program is cancelled.        |
|                                                                      |
|10.  During execution of an explicit or implicit CANCEL statement, an |
|     implicit CLOSE statement without any optional phrases is executed|
|     for each file in the open mode that is associated with an        |
|     internal file connector in the program named in the CANCEL       |
|     statement.  Any USE procedures associated with any of these files|
|     are not executed.                                                |
|                                                                      |
________________________________________________________________________
            
________________________________________________________________________
|(MF)                                                                  |
|                                                                      |
|                                                                      |
|                                                                      |
|11.  If literal-1 or the value in identifier-1 includes an extension, |
|     for example "ABC.gnt", or a path name such as "d:\xyz\ABC" on    |
|     DOS, or "/xyz/ABC" on UNIX, then the results of the CANCEL       |
|     statement are undefined.  In many operating systems this will    |
|     actually cause any currently called program "ABC" to be cancelled|
|     even if the currently called version was originally called with a|
|     different extension such as "ABC.int" or a path such as          |
|     "c:\lmn\ABC" on DOS, or "/lmn/ABC" on UNIX, or both.  See        |
|     your COBOL System Reference for any extensions which have        |
|     explicitly defined meanings for the CANCEL statement in your     |
|     environment.                                                     |
|                                                                      |
________________________________________________________________________
            
12.  The CANCEL statement determines whether or not a subprogram will be
     re-entered in initial or last-used state.  It does not necessarily
     free any memory used by the subprogram.  However, in many operating
     systems this statement will also free the memory originally used by
     the subprogram.  EXTERNAL files and data areas of the subprogram are
     never freed by a CANCEL statement.
The CHAIN Statement 
(MF)
Function 
The CHAIN statement transfers control from one object program to another
within the rununit with no subsequent return of control.
General Format 
            
________________________________________________________________________
|(MF)                                                                  |
|                                                                      |
|Syntax Rules                                                          |
|                                                                      |
|                                                                      |
|   1.  Identifier-1 must be defined as an alphanumeric data           |
|       item.                                                          |
|                                                                      |
|   2.  Literal-1 must be a nonnumeric literal.                        |
|                                                                      |
|   3.  The USING phrase is included in the CHAIN statement only if    |
|       there is a USING phrase in the PROCEDURE DIVISION header of the|
|       chained program.  The number of operands in the two USING      |
|       phrases can be unequal (see the section "The PROCEDURE DIVISION|
|       Header"  earlier in this chapter).                          |
|                                                                      |
|   4.  Each of the operands in the USING phrase must have been        |
|       defined as a data item in the File Section, Working-Storage    |
|       Section, Communication Section or Linkage Section.  Each       |
|       operand must have a level-number of 01 through 49 or           |
|       77.                                                            |
|                                                                      |
|   5.  Literal-2 must be non numeric and cannot be a figurative       |
|       constant.                                                      |
|                                                                      |
|   6.  Record-name must be the name of an 01 or 77 level item in the  |
|       Linkage or Working-Storage Section.                            |
________________________________________________________________________
            
________________________________________________________________________
|(MF)                                                                  |
|                                                                      |
|General Rules                                                         |
|                                                                      |
|                                                                      |
|   1.  The execution of a CHAIN statement causes control to           |
|       pass to the chained program as the main program in a           |
|       new run unit.  After control has been transferred, the         |
|       chaining program and all other programs in its run unit are    |
|       cancelled.                                                     |
|                                                                      |
|   2.  The chain operation moves the value from each data item        |
|       referenced in the USING phrase of the CHAIN statement to the   |
|       data item referenced by the corresponding data-name in the     |
|       USING phrase of the PROCEDURE DIVISION header of the chained   |
|       program.                                                       |
|                                                                      |
|   3.  A chained program cannot be a nested program.                  |
|                                                                      |
|   4.  Chained programs can contain CHAIN statements.  A chained      |
|       program can chain directly or indirectly to the program from   |
|       which it was chained.                                          |
________________________________________________________________________
            
 
  
  
  
 
 MPE/iX 5.0 Documentation