COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
23 Calling Other Programs and Routines
NOTE: This section applies to the Guardian environment. For information on mixed-language
programming in the OSS environment, see Mixed-Language Programs (page 712) and Utility Routines
(page 724).
An HP COBOL program that calls one or more non-COBOL routines is called a mixed-language
program (as is a non-COBOL program that calls one or more COBOL programs).
HP COBOL programs can call programs compiled by these compilers:
• TNS/E C
• TNS/E C++
• EpTAL
A called routine can have an ordinary, VARIABLE, or EXTENSIBLE parameter list.
Topics:
• Run-Time Environment
• Calling Other COBOL Programs
• Calling Non-COBOL Routines
• Passing Parameters
To call your HP COBOL program from a non-COBOL program, use the non-COBOL language’s
method of calling an external routine. The method varies from language to language; see the
reference manual for the appropriate non-COBOL language.
Run-Time Environment
Native programs always run in the CRE.
In the CRE, each routine in the program appears to be running in its own language-specific run-time
environment, regardless of the language of the main routine. For example, if the main routine of
a mixed-language program is written in HP COBOL, an HP C routine still has complete access to
the HP C run-time library.
The CRE library, a collection of routines that implements the CRE, enables the language-specific
run-time libraries to coexist peacefully with each other. User routines and run-time libraries call
CRE library routines to access shared resources managed by the CRE, such as the standard files
(input, output, and log) and the user heap, regardless of language.
The CRE does not support all possible operations. For example, the CRE supports file sharing only
for the three standard files: standard input, standard output, and standard log. The language-specific
run-time libraries access all other files by calling run-time procedures directly, whether or not a
program uses the CRE.
For more information about writing programs that use the services provided by the CRE, see the
CRE Programmer’s Guide.
Calling Other COBOL Programs
An HP COBOL program calls another HP COBOL program with a CALL statement. The called
program can be either a separately compiled HP COBOL program or a nested HP COBOL program.
A nested program is usually accessible to more calling programs if it is a common program.
If a called program is an initial program, its program state is initialized whenever it is called.
794 Calling Other Programs and Routines










