COBOL Manual for TNS/E Programs (H06.03+)

Source Program Organization and Format
HP COBOL Manual for TNS/E Programs520347-003
2-18
Shared Data
* Accessibility: Which Routines Can Access Which Data Names?
* -----
* Mane Aaa Bbb Ccc Ddd Sub Item
* ---- --- --- --- --- --- -------------
* L . . . . . w of Mane
* / . L . . . w of Bbb
* / . . L . . w of Ccc
* / . . . . L w of Sub
* . . L G G . x of Bbb
* . . . . . L x of Sub
* L G G / G . y of Mane
* . . . L . . y of Ccc
* . . . . . L y of Sub
* L G G G G . z of Mane
* . . . . . L z of Sub
*
* ( L = access because it is locally defined)
* ( G = access because ancestor declared it global)
* ( / = can't access global because of local definition)
* ( . = can't access because no local or global definition)*
* Storage 1. W of Bbb, w of Ccc, and w of Sub all refer to one location
* Allocation
* 2. Z of Mane and z of Sub each refer to one location.
*
* 3. All other identifiers refer to unique locations.
?main Mane
IDENTIFICATION DIVISION.
PROGRAM-ID. Mane.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 w PICTURE 99 VALUE 3.
01 y PICTURE 99 GLOBAL VALUE 1.
01 z picture 99 GLOBAL EXTERNAL.
PROCEDURE DIVISION.
m.
DISPLAY "Mane begin"
MOVE 25 to z
PERFORM show-me
CALL Aaa PERFORM show-me
CALL Bbb PERFORM show-me
CALL Sub PERFORM show-me
CALL Sub PERFORM show-me
DISPLAY "Mane end"
stop run
.
show-me.
DISPLAY "in Mane, w=/" w "/ y=/" y "/ z=/" z "/"
.
Example 2-2. Programs With Shared Data (page 2 of 4)