Compaq AAQ2G1FTK Marine Radio User Manual


 
Interprogram Communication
12.5 Communicating with Contained COBOL Programs
At run time, two special precedence rules apply for the selection of a declarative
when programs are contained in other programs. In applying these two rules,
only the first qualifying declarative is selected for execution. The order of
precedence for the selection of a declarative follows:
Rule 1 —The declarative that executes first is the declarative within the
program containing the statement that caused the qualifying condition. In
Figure 12–6, FILE-NAME-PROBLEM procedure executes.
Figure 126 Executing Declaratives with Contained Programs (Rule 1)
IDENTIFICATION DIVISION.
PROGRAMID. MAINPROGRAM.
.
.
.
IDENTIFICATION DIVISION.
PROGRAMID. SUB1.
.
.
.
IDENTIFICATION DIVISION.
PROGRAMID. USEPROGRAM.
.
.
.
PROCEDURE DIVISION.
DECLARATIVES.
FILENAMEPROBLEM SECTION.
USE AFTER STANDARD ERROR PROCEDURE ON FILEA.
OPEN INPUT FILEA.
.
.
.
END PROGRAM USEPROGRAM.
END PROGRAM SUB1.
END PROGRAM MAINPROGRAM.
3
2
1
ZK1428AGE
Rule 2 —If a declarative is not found using Rule 1, the Run-Time System
searches all programs directly or indirectly containing that program for a
global use procedure. This search continues until the Run-Time System
either: ( 1 ) finds an applicable USE GLOBAL declarative, or ( 2 ) finds the
outermost containing program. Either condition terminates the search; the
second condition terminates both the search and the run unit.
Figure 12–7 shows applicable USE GLOBAL declaratives found in a containing
program before the outermost containing program. Note that the first OPEN goes
to the mode-specific procedure in the USE-PROGRAM rather than the file-specific
procedure in the MAINPROG-PROGRAM.
For information on the negative effect of USE procedures that reference
LINKAGE SECTION items on compiler optimization, see Section 15.5.5,
Minimizing USE Procedures with LINKAGE SECTION References .
Interprogram Communication 1217