COBOL Manual for TNS and TNS/R Programs

Calling Other Programs and Routines
HP COBOL Manual for TNS and TNS/R Programs522555-006
23-23
What HP COBOL Can Pass by Reference
What HP COBOL Can Pass by Reference
An HP COBOL program can pass these to non-COBOL routines by reference:
Elementary Data Items
Records
Elementary Data Items
The only elementary data items that HP COBOL programs can always pass by
reference are NATIVE-2, NATIVE-4, NATIVE-8, and PICTURE X (n ) data items. If an
external routine stores an integer value in a COMPUTATIONAL numeric data item, and
that value exceeds HP COBOL’s limits (4 decimal digits for 16 bits of storage, 9
decimal digits for 32 bits of storage, and 18 decimal digits for 64 bits of storage),
results from using the contents of that data item are unpredictable—the program might
work as expected, not work as expected, or terminate abnormally.
HP COBOL programs can also pass by reference a numeric data item with a PICTURE
containing V or P, but only if the corresponding formal parameter is the equivalent of
an 8-byte integer and the HP COBOL program and external routine agree on an
interpretation.
Some values on NonStop systems that fit into a HP COBOL data item described as
PICTURE S9(n -s)V9(s ) COMPUTATIONAL exceed HP COBOL’s limits. More
importantly, HP COBOL generates computational code based on the descriptions of
data items, so if an external routine installs a value in a PICTURE S9(n -s )V9(s )
COMPUTATIONAL field that HP COBOL could not have stored, the computational
results could be invalid.
Records
HP COBOL programs must pass record parameters by reference.
What HP COBOL Can Pass by Value
A HP COBOL program can pass these types of items to non-COBOL routines by
value:
Numeric literals
Numeric data items
Special registers
Arithmetic expressions
If a parameter is passed by value, it is evaluated, scaled, and converted to the storage
size and type of the formal parameter. The resulting value is passed to the called
routine. This conversion might cause an arithmetic overflow.