COBOL Manual for TNS/E Programs (H06.03+)

Calling Other Programs and Routines
HP COBOL Manual for TNS/E Programs520347-003
23-7
X/Open CALL Statement
In the ENTER statement, you do not need to specify the language of the called routine,
because the compiler can determine the language in which the program is written. If
you do specify the language, it must be C or TAL. If you specify TAL, the compiler
expects a pTAL program (it does not accept TAL programs). If you specify C, the
compiler expects a routine written in either HP C or HP C++. Although an HP COBOL
program can use the ENTER statement to call HP C++ and pTAL programs, you
cannot specify the language C++ or pTAL.
Any non-COBOL routine called by an HP COBOL program must have already been
compiled, and its object program forms must be available to the compiler through a
DLL, import library, or object file, specified through the SEARCH or CONSULT
directive.
X/Open CALL Statement
If an HP COBOL program is compiled with the PORT directive, it can call non-COBOL
routines with the CALL statement, which behaves like an X/Open CALL statement.
If the called program is a function, the X/Open CALL statement returns its value in the
special register RETURN-CODE. For more information, see Special Register
RETURN-CODE.
Functions (Routines That Return Values)
A function is a routine that returns a value to the calling program. COBOL has no
mechanism for returning a function’s value to the calling program, but HP COBOL has
two:
GIVING Phrase
Special Register RETURN-CODE
GIVING Phrase
The GIVING phrase allows you to specify a data item, return-value, to hold the
value that the function returns. The storage operation is performed after any necessary
scaling and follows the rules for an elementary MOVE TO statement (for these rules,
see MOVE TO).
Caution. If a program compiled with the PORT directive calls a program not compiled with the
PORT directive, differences in the way BINARY/COMPUTATIONAL/COMP data items are
aligned in the two programs can cause data to be misread.