COBOL Manual for TNS and TNS/R Programs
Source Program Organization and Format
HP COBOL Manual for TNS and TNS/R Programs—522555-006
2-19
Shared Data
Example 2-2. Programs With Shared Data (page 1 of 4)
* _______________________________________________________________________
* | Program: Mane |
* | Data: w (local to Mane) |
* | y (global throughout Mane and its descendants) |
* | z (global throughout Mane and its descendants, and external) |
* | Can call: Aaa, Bbb because both are directly contained |
* | _________________________________________________________________ |
* | | Program: Aaa | |
* | | Data: none | |
* | | Can call: Bbb because Bbb is common | |
* | | Sub because Sub is separate unit | |
* | |_________________________________________________________________| |
* | | Program: Bbb (common) | |
* | | Data: w (external) | |
* | | x (global throughout Bbb) | |
* | | Can call: Ccc because Ccc is directly contained | |
* | | Sub because Sub is separate unit | |
* | | ____________________________________________________ | |
* | | | Program: Ccc | | |
* | | | Data: w (external) | | |
* | | | y (local to Ccc) | | |
* | | | Can call: Ddd because Ddd is directly contained | | |
* | | | Sub because Sub is separate unit | | |
* | | | ______________________________________________ | | |
* | | | | Program: Ddd | | | |
* | | | | Data: none | | | |
* | | | | Can call: Sub because Sub is separate unit | | | |
* | | | |______________________________________________| | | |
* | | |___________________________________________________| | |
* | |_________________________________________________________________| |
* |_______________________________________________________________________|
* | Program: Sub |
* | Data: w (external) |
* | x (local to Sub) |
* | y (global throughout Sub and any descendants) |
* | z (global throughout Sub and any descendants, and external) |
* | Can call: no other routines (calling Mane would be recursion) |
* |_______________________________________________________________________|
*
* 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)*