COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-27
CALL
•
Storage Allocation
For programs with the INITIAL attribute, HP COBOL uses dynamic storage
allocation, allocating space for data items in the Working-Storage Section each
time the program is called and releasing it each time the program is exited. This
can cause stack overflow, which can cause the run unit to terminate abnormally.
For programs without the INITIAL attribute, HP COBOL allocates space at the start
of execution of the run unit for all program data except internal data, which it
allocates when the program is called. It is unlikely that allocating space for internal
data (usually a small amount) will cause stack overflow.
•
Passing Parameters
Parameters passed by the USING phrase are data items from a calling program
that the called program can reference.
•
Correspondence of Formal and Actual Parameters
The formal parameters in the USING phrase of the Procedure Division header and
the actual parameters in the USING phrase of the CALL statement correspond by
position, not by name.
•
Declaration Locations and Access Modes of Formal and Actual Parameters
You must declare formal parameters in the Linkage Section. For a TNS program, a
parameter declared in the Linkage Section has EXTENDED-STORAGE access
mode (a 32-bit address) unless you specify STANDARD access mode (a 16-bit
address). For a native program, every parameter has a 32-bit address. If you
specify STANDARD access mode, the NMCOBOL compiler ignores it and issues a
warning.
If a formal parameter has EXTENDED-STORAGE access mode, its corresponding
actual parameter can have either STANDARD or EXTENDED-STORAGE access
mode. If a formal parameter has STANDARD access mode, its corresponding
actual parameter must also have STANDARD access mode.
For an actual parameter to have STANDARD access mode, you must declare it in
the File Section or Working-Storage Section.
If you declare an actual parameter in the Linkage Section of the calling program
and pass it to a formal parameter whose access mode is STANDARD, the
COBOL85 compiler reports an error, but the program might work.
•
Parameter Validation
The COBOL85 and NMCOBOL compilers report errors under these conditions:
°
The number of actual parameters (in the CALL statement) differs from the
number of formal parameters (in the Procedure Division heading).
°
For a TNS program, the access mode of an actual parameter is incompatible
with that of its corresponding formal parameter.