COBOL Manual for TNS/E Programs (H06.03+)
Calling Other Programs and Routines
HP COBOL Manual for TNS/E Programs—520347-003
23-22
Passing Parameters to Non-COBOL Routines
If a parameter is passed by reference so that the called routine can return a value to
the calling program, the parameter declaration must match the expectation of the
called routine, because HP COBOL code does not convert the values upon return from
the routine.
A COBOL program cannot pass a program name (a program-name in a PROGRAM-
ID paragraph) to a non-COBOL routine as a parameter.
Topics:
•
HP C or HP C++
•
pTAL
HP C or HP C++
•
A HP COBOL program can pass numeric arguments to an HP C or HP C++ routine
either by reference or by value.
•
A HP COBOL program must pass nonnumeric arguments to an HP C or HP C++
routine by reference.
•
If the data type of a value parameter differs from the data type of the corresponding
formal parameter, the compiler converts the value of the value parameter to the
data type of the formal parameter. If the value is outside the range of values
allowed for the HP C or HP C++ data type, an arithmetic trap occurs.
•
The compiler cannot convert reference parameters to different data types.
•
A HP COBOL program can pass an integer (NATIVE-2, NATIVE-4, or NATIVE-8)
data item to an HP C or HP C++ routine either as a reference parameter or by an
external declaration. In both cases, the HP C or HP C++ routine receives the
integer as a pointer type.
•
The GIVING phrase cannot be specified in an ENTER statement that accesses an
HP C or HP C++ function whose type is a pointer.
For more information about HP C or HP C++ routines and modules, see the C/C++
Programmer’s Guide and the Guardian Native C Library Calls Reference Manual.
In Example 23-5, an HP COBOL program uses reference parameters to pass integer
data items to a C routine. On return from the ENTER statement in the HP COBOL
code, SQ contains the product of PAR1, PAR2, and PAR3, and the value of PAR3 is
25.










