Executing Declaratives With Contained Programs (Rule 1) - Compaq COBOL AAQ2G1FTK User Manual

Compaq computer accessories user manual
Table of Contents

Advertisement

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 12–6 Executing Declaratives with Contained Programs (Rule 1)
IDENTIFICATION DIVISION.
PROGRAM−ID.
.
.
.
IDENTIFICATION DIVISION.
PROGRAM−ID.
.
.
.
IDENTIFICATION DIVISION.
PROGRAM−ID.
.
.
1
.
PROCEDURE DIVISION.
DECLARATIVES.
2
FILE−NAME−PROBLEM SECTION.
USE AFTER STANDARD ERROR PROCEDURE ON FILEA.
3
OPEN INPUT FILEA.
.
.
.
END PROGRAM
END PROGRAM
END PROGRAM MAIN−PROGRAM.
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
MAIN−PROGRAM.
SUB1.
USE−PROGRAM.
USE−PROGRAM.
SUB1.
Interprogram Communication 12–17
ZK−1428A−GE

Advertisement

Table of Contents
loading

Table of Contents