[an error occurred while processing this directive]
HP OpenVMS Systems Documentation |
HP COBOL
|
Previous | Contents | Index |
When a source program declares condition-names, data-names, file-names, record-names, report-names, and segmented-key-names, only the declaring source program can reference these names. The only exception is when names have the GLOBAL attribute and the program contains other programs.
For example, when a program such as PROG-NAME-A (See (1) in Example 6-9) contains other programs (PROG-NAME-B (10) and PROG-NAME-C (25)), each program can define the same user-defined word. When such duplicated names are referenced, the rules for qualification of names (see Section 6.2.1) apply; and, if necessary, the following three hierarchical rules resolve any ambiguity:
Example 6-9 Resolving References to Miscellaneous Names |
---|
IDENTIFICATION DIVISION. PROGRAM-ID. PROG-NAME-A. (1) DATA DIVISION. FILE SECTION. FD FILE-NAME ...(2) 01 RECORD-NAME ...(3) FD GLOBAL-FILE-NAME... IS GLOBAL... WORKING-STORAGE SECTION. 01 EXAMPLE1 ... IS GLOBAL... 01 EXAMPLE2 ... IS GLOBAL... 01 EXAMPLE3 ... IS GLOBAL... 01 SWITCH-STATUS. (4) 88 ON VALUE IS "1". 88 OFF VALUE IS "0". 01 DATA-NAME ...(5) PROCEDURE DIVISION. MOVE DATA-NAME TO ...(6) IF SWITCH-STATUS IS ON ...(7) MOVE RECORD-NAME TO ...(8) OPEN INPUT FILE-NAME ...(9) IDENTIFICATION DIVISION. PROGRAM-ID. PROG-NAME-B. (10) DATA DIVISION. FILE SECTION. FD FILE-NAME ...(11) 01 RECORD-NAME ...(12) WORKING-STORAGE SECTION. 01 SWITCH-STATUS. (13) 88 ON VALUE IS "1". 88 OFF VALUE IS "0". 01 DATA-NAME ...(14) 01 EXAMPLE2 ...(15) 01 EXAMPLE3 ... IS GLOBAL... 01 EXAMPLE4 ... IS GLOBAL... PROCEDURE DIVISION. MOVE DATA-NAME TO ...(16) IF SWITCH-STATUS IS ON ...(17) MOVE RECORD-NAME TO ...(18) OPEN INPUT FILE-NAME ...(19) OPEN OUTPUT GLOBAL-FILE-NAME. (20) MOVE EXAMPLE1 ...(21) MOVE EXAMPLE2 ...(22) MOVE EXAMPLE3 ...(23) MOVE EXAMPLE4 ...(24) IDENTIFICATION DIVISION. PROGRAM-ID. PROG-NAME-C. (25) WORKING-STORAGE SECTION. 01 EXAMPLE2 ...(26) 01 EXAMPLE4 ...(27) PROCEDURE DIVISION. OPEN OUTPUT GLOBAL-FILE-NAME. MOVE EXAMPLE1 ... MOVE EXAMPLE2 ...(28) MOVE EXAMPLE3 ...(29) MOVE EXAMPLE4 ... END PROGRAM PROG-NAME-C. END PROGRAM PROG-NAME-B. END PROGRAM PROG-NAME-A. |
If a data item possesses either or both the EXTERNAL or GLOBAL attributes and includes a table defining an index-name, that index-name also possesses either or both attributes.
If the file associated with a segmented key possesses either or both
the EXTERNAL or GLOBAL attributes, that segmented key also possesses
either or both attributes.
6.2.7 External and Internal Data
External data is associated with a run unit. Any program in the run unit describing the external data can reference that data. (See the Section 5.3.21 clause in Chapter 5.) There is only one representation of an external data object.
Internal data is associated with a specific program.
External and internal data can have global names. (See the
Section 5.3.25 clause in Chapter 5.)
6.3 Explicit and Implicit Specifications
The four types of explicit and implicit specifications follow:
A source program can refer to data items explicitly or implicitly in Procedure Division statements.
An explicit reference occurs when the name of the item is in a Procedure Division statement or copied into the Procedure Division by a COPY statement.
An implicit reference occurs under the following conditions:
The mechanism that controls program flow implicitly transfers control from one statement to another in the order in which the statements appear in the source program. The transfer occurs in this sequence unless an explicit control transfer overrides it, or there is no next executable statement.
A program can contain both explicit and implicit changes to the control transfer mechanism.
Implicit control transfer can also occur when normal program flow changes without executing a procedure-branching statement. For example:
An explicit control transfer is a change to the implicit control transfer mechanism caused only by execution of either:
The EXIT procedure-branching statement causes an explicit control transfer only when it has the PROGRAM phrase.
The Procedure Branching statement ALTER does not cause an explicit control transfer. However, it affects the explicit control transfer of the associated GO TO statement.
The term next executable statement refers to the next COBOL statement to which control transfers according to these rules and those associated with each language element.
There is no next executable statement when the program has no Procedure Division. This is also the case after:
When there is no next executable statement and control does not transfer out of the program, program control flow is undefined. However, an EXIT PROGRAM statement implicitly executes when the program is under the control of a CALL statement.
Previous | Next | Contents | Index |