Compaq AAQ2G1FTK Marine Radio User Manual


 
Interprogram Communication
12.1 Multiple COBOL Program Run Units
Example 12–1 Run Unit with Three Separately Compiled Programs
IDENTIFICATION DIVISION. IDENTIFICATION DIVISION.
PROGRAM-ID. MAIN-PROGRAM.
1
PROGRAM-ID. SUB1.
2
..
..
..
CALL SUB1. CALL SUB2.
..
..
..
STOP RUN. EXIT PROGRAM.
END PROGRAM MAIN-PROGRAM END PROGRAM SUB1.
IDENTIFICATION DIVISION.
PROGRAM-ID. SUB2.
3
.
.
.
EXIT PROGRAM.
END PROGRAM SUB2.
Note
A separately compiled program has a nesting level number of 1. If this
program contains other source programs, it is the outermost containing
program. A contained program has a nesting level number greater
than 1.
Example 12–2 shows a run unit with one main program (
4
) and two contained
programs (SUB1 (
5
) is a directly contained program of MAIN-PROGRAM; SUB2
(
6
) is an indirectly contained program of MAIN-PROGRAM).
Example 12–3 shows a run unit with three separately compiled programs (
7
,
10
,
and
11
). One of the separately compiled programs, MAIN-PROGRAM (
7
), has
two directly contained programs, SUB1 and SUB2 (
8
and
9
).
12.1.2 Calling Procedures
A COBOL main (driver) program calls subprograms (contained or separately
compiled). Image execution begins and ends in the main program’s Procedure
Division. The program contains one or more CALL statements and is a calling
program.
A COBOL subprogram is called by a main program or another subprogram. The
subprogram may or may not contain CALL statements. If a subprogram contains
a CALL statement, it is both a calling and a called program. If the subprogram
does not contain a CALL statement, it is a called program only.
12–2 Interprogram Communication