Compaq COBOL AAQ2G1FTK User Manual

Page 449

Advertising
background image

Interprogram Communication

12.5 Communicating with Contained COBOL Programs

Because you cannot specify a Configuration Section for a program contained
within another program, the following types of user-defined words are always
global; that is, they are always accessible from within a contained program:

Alphabet-name

Class-name

Condition-name

Mnemonic-name

Symbolic-character

These user-defined words can be referenced by statements and entries either in
the program that contains the Configuration Section or any program contained in
that program.

12.6 Calling Compaq COBOL Programs from Other Languages

The CALL and CANCEL verbs allow you to call and cancel Compaq COBOL
programs (including routines and separately compiled program units) from within
a Compaq COBOL program. The

cobcall

,

cobcancel

, and

cobfunc

RTL calls

allow you to call and cancel those programs from programs written in other
languages.

When you use

cobcall

,

cobcancel

, and

cobfunc

, the same considerations and

results will be in effect as if you had used the CALL and CANCEL statements
(see Section 12.1.2 and Section 12.3).

If you need both a CANCEL (to reinitialize data) and a CALL, you can code it
with a single

cobfunc

call.

cobfunc

is essentially a jacket that calls

cobcancel

and

cobcall

.

Table 12–1 shows these calls and their basic differences.

Table 12–1 Calls to COBOL Programs

RTL Call

Function

cobcall

Calls a COBOL program. Program variables remain in their last state.

cobcancel

Cancels a COBOL program. Program variables are reset.

cobfunc

Calls a COBOL program then cancels it. Program variables are reset on
exit.

12.6.1 Calling COBOL Programs from C

Using cobfunc.h as shown in Example 12–8, the C code in Example 12–7
demonstrates a program that calls a COBOL program with three arguments.
In this example the COBOL program, CALLEDFROMC, expects two strings and
an integer.

Example 12–8 could be used as an #include file for the

cobfunc

,

cobcall

, and

cobcancel

functions.

Interprogram Communication 12–19

Advertising