COBOL Manual for TNS and TNS/R Programs

Source Program Organization and Format
HP COBOL Manual for TNS and TNS/R Programs522555-006
2-16
Global and Local Names
Global and Local Names
A data-name (which names a data item) or a file-name (which names a file connector)
can be either global or local.
Suppose that program X declares data-name Y, and program X contains program Z,
which also declares data-name Y. When program Z references data-name Y, it is
referencing the Y that it declared, not the Y that program X declared, whether program
X declared its Y to be global or not.
Some names are always global; other names are always local; and some names are
either global or local, depending on specifications in the program that declares the
names:
In some circumstances, a data description, file description, or record description entry
cannot specify the GLOBAL clause (see GLOBAL Clause).
If a data-name, file-name, or condition-name declared in a data description entry is not
global, the name is local.
Global names are inherited by contained programs. Suppose program OUTER
declares a name X to be global and contains program INNER, which contains program
INNERMOST. As long as program INNER does not define the name X explicitly, a
reference to X in INNER refers to the X defined in OUTER. Also, as long as program
INNERMOST does not define the name X and program INNER does not define X as a
global name, a reference to X in INNERMOST refers to the X defined in OUTER.
Global names, as well as local names, can be associated with external and internal
objects.
Name It is global if a GLOBAL clause is in …
Record-name its record description entry
or
the file description entry for the file-name associated with its record
description entry (if the record-name is in the File Section)
Data-name its record description entry
Condition-name an entry to which its data description entry is subordinate (that is, if a
data-name is declared global, all condition-names subordinate to it are
automatically global)
File-name its file description entry