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

Calling Non-COBOL Routines
The way an HP COBOL program can call a non-COBOL routine depends on whether the calling
program was compiled with the PORT directive. An HP COBOL program that was not compiled
with the PORT directive calls a non-COBOL routine with the ENTER statement. An HP COBOL
program that was compiled with the PORT directive calls a non-COBOL routine with either the
ENTER statement or the CALL statement, which behaves like an X/Open CALL statement.
NOTE: If the types of the actual and formal parameters do not match, the ENTER statement
attempts to convert the actual parameters to the types of the formal parameters; the X/Open CALL
statement reports an error instead.
Applying a CANCEL statement to a non-COBOL routine that was called with an X/Open CALL
statement terminates the run unit.
Topics:
ENTER Statement
X/Open CALL Statement
Functions (Routines That Return Values)
Operating System Routines
HP COBOL Run-Time Routines
COBOL Utility Routines
ENFORM Programs
Restrictions on Calling Non-COBOL Routines
ENTER Statement
If an HP COBOL program is not compiled with the PORT directive, it can call routines written in
native HP C, native HP C++, and pTAL by using the ENTER 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.
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.
798 Calling Other Programs and Routines