COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Enabling HP COBOL to obtain a numeric value from a single byte requires a work-around in
the HP COBOL program. In your HP COBOL program, define a corresponding parameter
and a temporary storage area, as in Example 253.
Example 253 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.
In Example 253, 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.
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.
808 Calling Other Programs and Routines










