COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Scaling of the function’s value (if needed) is performed before the value is assigned to
return-value. If the function’s value is larger than the maximum value allowed for a COBOL
identifier, the COBOL program terminates with an arithmetic overflow condition during the
conversion process. The assignment operation follows MOVE conventions (see MOVE TO
(page 368)).
• Passing Parameters by Value
When a formal parameter (in the called routine) is to be passed by value, the actual parameter
(in the ENTER statement) must be a numeric literal, a numeric data item, a special register,
an arithmetic expression, or the word OMITTED. If the parameter is not OMITTED, it is
evaluated, scaled, and converted to the storage size and type of the formal parameter. The
resulting value is passed to the called routine. This conversion might cause an arithmetic
overflow.
• Passing Parameters by Reference
When a formal parameter (in the called routine) is to be passed by reference, the actual
parameter (in the ENTER statement) must be a data item or, in some routines supplied by HP,
a file name.
If the actual parameter is a data item, the compiler generates code to pass the address of the
data item’s storage space to the called routine. The calling program and the called routine
must interpret the value of the data item the same way.
If the actual parameter is a file name, the compiler generates code to pass the address of the
COBOL file control block to the called routine.
• Addressing Parameters
All instructions use 32-bit addressing. Many COBOL data items are byte-addressed. Some
data items in other languages are 2-byte-addressed. When you pass a byte-addressed
parameter to a routine that expects a 2-byte-addressed parameter, the data item must be
aligned on a 2-byte boundary; otherwise, problems can arise, because the called routine is
expecting an aligned parameter. The compiler does not issue a warning in this case.
◦ pTAL
In pTAL modules, each data item declaration (including parameter declarations) specifies
either 1-byte or 2-byte addressing. All declarations use 32-bit addressing.
◦ C and C++
In HP C and HP C++ modules, all data item declarations (including parameter declarations)
use 32-bit addressing.
• Restrictions on Calling HP C and HP C++ Functions
An HP COBOL program cannot call an HP C or HP C++ function for which any of these
conditions are true:
◦ The function name includes lowercase letters.
◦ The function prototype specifies a variable number of parameters.
◦ The function returns a structured value.
◦ The function specifies a formal parameter whose type has no corresponding COBOL type
(see Appendix B: Data Type Correspondence (page 1234)).
Do not include the GIVING phrase in an ENTER statement that accesses an HP C or HP
C++ function whose type is a pointer.
Because the names of HP C++ routines are often modified to reflect their classes and
argument types, it is recommended that HP COBOL programs call only regular HP C++
322 Procedure Division Verbs










