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-24
Passing Parameters to COBOL Programs
Passing Parameters to COBOL Programs
A COBOL program can pass parameters to another COBOL program with the CALL
statement.
A non-COBOL routine can pass parameters to a COBOL program with the non-
COBOL language’s method of calling an external routine. The method varies from
language to language; see the reference manual for appropriate non-COBOL
language.
Topics:
•
From HP COBOL Programs
•
From Non-COBOL Routines
From HP COBOL Programs
By default, the CALL statement passes parameters by reference. This means that the
called program can change the value of the parameter that is stored in the calling
program.
You can specify that the CALL statement is to pass a parameter by content instead of
by reference. This means that the called program cannot change the value of the
parameter that is stored in the calling program. To specify that a parameter is to be
passed by content, specify CONTENT in a USING phrase in the CALL statement.
A COBOL program can pass a program name (a program-name in a PROGRAM-ID
paragraph) as a parameter to another COBOL program (see Dynamic Calls).
From Non-COBOL Routines
When calling a COBOL program from a non-COBOL program, remember that:
•
A non-COBOL program must pass any parameters to COBOL program by
reference.
•
A non-COBOL program cannot pass a program name (a program-name for a
PROGRAM-ID paragraph) to a COBOL program as a parameter.
•
COBOL has no single-byte numeric data type that corresponds to:
°
HP C and C++ data types char and unsigned char
°
Pascal data type BYTE
°
pTAL data types UNSIGNED(8) and STRING
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 23-4.