COBOL Manual for TNS and TNS/R Programs

Calling Other Programs and Routines
HP COBOL Manual for TNS and TNS/R Programs522555-006
23-25
Passing Parameters to Non-COBOL Routines
In Example 23-4, when a non-COBOL routine (or a READ statement) has delivered a
value to STRUCT-M, the HP COBOL program must move a numeric zero to ONE-
WORD-NUMERIC and move the single-byte numeric value from either Y or Z into
LOW-HALF. Then the HP COBOL program can use ONE-WORD-NUMERIC as a
numeric value. For example, this code tests whether the value of Y is greater than 9:
MOVE ZEROS TO ONE-WORD-NUMERIC.
MOVE Y TO LOW-HALF
IF ONE-WORD-NUMERIC > 9
...
Passing Parameters to Non-COBOL Routines
Whether the ENTER statement passes parameters by reference or by value depends
on what the called routine requires. The compiler determines whether the called
routine requires a reference parameter or a value parameter. If the called routine
requires a reference parameter, the compiler generates code that passes an address;
if the called routine requires a value parameter, the compiler generates code that
passes a value. (A called program can change the value of a reference parameter but
not a value parameter.)
If the compiler cannot locate the object form of the called program or routine, or at least
a dummy version that describes the expected parameters, then it cannot determine
whether the parameters are to be passed by reference; therefore, it cannot generate
the appropriate code, so it reports an error and does not produce an object program.
Example 23-4. TAL/pTAL Structures for Passing Parameters to COBOL Program
TAL or pTAL declaration:
STRUCT M;
BEGIN
INT X;
STRING Y;
UNSIGNED(8) Z;
END;
Corresponding HP COBOL parameter:
01 STRUCT-M.
03 X USAGE NATIVE-2.
03 YZ.
05 Y PIC X.
05 Z PIC X.
HP COBOL temporary storage area:
01 TEMP-COMP.
03 ONE-WORD-NUMERIC USAGE NATIVE-2.
03 CHEATER REDEFINES ONE-WORD-NUMERIC.
05 FILLER PIC X.
05 LOW-HALF PIC X.