The Global Clause; Sharing Global Data; Sharing Global Files - Compaq COBOL AAQ2G1FTK User Manual

Compaq computer accessories user manual
Table of Contents

Advertisement

PROG-MAIN (
contains PROG-NAME-B. PROG-NAME-B (
because PROG-NAME-B directly contains PROG-NAME-D.
PROG-NAME-C (
PROG-NAME-C is not contained in PROG-NAME-B
PROG-NAME-B has the common attribute
PROG-NAME-C is contained by PROG-MAIN
However, PROG-NAME-D (
NAME-D (
(
) cannot call PROG-NAME-C (
3
to PROG-NAME-D (
call PROG-NAME-D (
NAME-D (
(
).
2

12.5.2 The GLOBAL Clause

Data and files can be described as either global or local. A local name can be
referenced only by the program that declares it. A global name is declared in
only one program but can be referenced by both that program and any program
contained in the program that declares the global name.
Some names are always global, other names are always local, and some names
are either local or global depending on specifications in the program that declares
the names. For more information on Scope of Names rules, see the Compaq
COBOL Reference Manual.

12.5.2.1 Sharing GLOBAL Data

A data name is global if the GLOBAL clause is specified in the Data Description
entry by which the data name is declared or in another entry to which that
Data Description entry is subordinate. If a program is contained within another
program, both programs may reference data possessing the global attribute. The
following example shows the Working-Storage Section of a containing program
MAINPROG. Any contained program in MAINPROG, as well as program
MAINPROG, can reference that data (unless the contained program declares
other data with the same name).
WORKING-STORAGE SECTION.
01
CUSTOMER-FILE-STATUS
01
REPLY
01
ACC-NUM

12.5.2.2 Sharing GLOBAL Files

A file connector is global if the GLOBAL clause is specified in the File Description
entry for that file connector. If a program is contained within another program,
both programs may reference a file possessing the global attribute. The following
example shows a file (CUSTOMER-FILE) with the GLOBAL clause in a
containing program MAINPROG. Any contained program in MAINPROG, as
well as program MAINPROG, can reference that file.
12.5 Communicating with Contained COBOL Programs
) can call PROG-NAME-B (
1
) can call PROG-NAME-B (
4
) cannot call PROG-NAME-B (
3
) is contained within PROG-NAME-B (
3
4
). If PROG-NAME-C (
3
). Additionally, PROG-NAME-C (
3
) because PROG-NAME-C (
3
PIC XX
PIC X(10)
PIC 9(18)
Interprogram Communication
) because PROG-MAIN directly
2
) can call PROG-NAME-D (
2
) because:
2
). Similarly, PROG-NAME-D
2
) because PROG-NAME-C (
) was made COMMON it could
4
4
) is outside the scope of PROG-NAME-B
4
GLOBAL.
GLOBAL.
GLOBAL.
Interprogram Communication 12–15
)
3
) because PROG-
2
) is not visible
4
) cannot call PROG-

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COBOL AAQ2G1FTK and is the answer not in the manual?

Questions and answers

Table of Contents