Compaq AAQ2G1FTK Marine Radio User Manual


 
Interprogram Communication
12.3 Transferring Flow of Control
Note
A program cannot cancel itself nor can any program cancel the program
that called it.
In COBOL programs, to call a routine named SPECIALROUTINE from an
overlying COBOL program you might use:
MOVE "SPECIALROUTINE" TO ROUTINE-NAME.
CALL ROUTINE-NAME.
If you need to call SPECIALROUTINE from a program in another language, use
cobcall
or
cobfunc
.
12.3.2 Nesting CALL Statements
A called subprogram can itself transfer control flow after receiving control from
a main program or another subprogram. This technique is known as CALL
statement nesting. For example, Figure 12–1 shows a nested image that executes
a series of three CALL statements from three separate programs.
Figure 12–1 Nesting CALL Statements
MAINPROG
ZK1475GE
SUB SUBA SUBB
1
6
2
5
3
4
MAINPROG calls SUB,
SUB then calls SUBA
SUBA then calls SUBB
The MAINPROG, SUB1, and SUB2 programs in Example 12–4 illustrate their
execution sequence by displaying a series of 12 messages on the default output
device. Image execution begins in MAINPROG with message number 1. It ends
in MAINPROG with message number 12. The image’s message sequence is
shown following the program listings.
Example 12–4 Execution Sequence of Nested CALL Statements
IDENTIFICATION DIVISION.
*
* MAINPROG is a calling program only
*
PROGRAM-ID. MAINPROG.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
(continued on next page)
12–6 Interprogram Communication