COBOL Manual for TNS and TNS/R Programs
Calling Other Programs and Routines
HP COBOL Manual for TNS and TNS/R Programs—522555-006
23-9
X/Open CALL Statement
X/Open CALL Statement
If an HP COBOL program is compiled with the PORT directive and runs in the CRE, 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 and it was compiled either by the COBOL85 compiler
with the ENV COMMON directive or by the NMCOBOL compiler, 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).
Special Register RETURN-CODE
The special register RETURN-CODE is accessible to an HP COBOL program that was
compiled with the PORT directive and uses the X/Open CALL statement to call a
function if either:
•
The HP COBOL program and the function are TNS programs that run in the CRE,
and the HP COBOL program was compiled with the ENV COMMON directive (not
the LIBRARY directive).
•
The HP COBOL program and the function are native programs.
The value of the function is returned in the special register RETURN-CODE, whose
description is:
01 RETURN-CODE EXTERNAL PICTURE S9(5) COMPUTATIONAL.
If the value of the function is greater than 99,999, arithmetic overflow occurs.
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.