COBOL Manual for TNS and TNS/R Programs
Data Division
HP COBOL Manual for TNS and TNS/R Programs—522555-006
7-36
Initializing Data Items
Initializing Data Items
The value to which a data item is initialized is determined by:
•
EXTERNAL clause
A data item described with an EXTERNAL clause (an external data item) cannot
have a VALUE clause and is not affected by events that cause internal data items
to be initialized. Its contents are unpredictable until a program assigns a value to it.
Thereafter, it retains the last value assigned to it throughout the current execution
of the run unit.
•
VALUE clause
With some exceptions, you can set the initial value of an internal data item by
including a VALUE clause in its data description entry (for exceptions, see VALUE
Clause).
•
BLANK and NOBLANK directives
When a data item is not described with a VALUE clause, the BLANK or NOBLANK
directive determines its initial value (see BLANK and NOBLANK).
An internal data item is initialized at each of these times:
•
The first time the program is executed.
•
The first time the program is called after a CANCEL statement that references it
has been executed, unless a NOCANCEL directive affects the program.
•
Every time the program is called, if the program is an initial program (see Initial
Programs). The NOCANCEL directive does not affect initial programs.
Once initialized, an internal data item retains the last value assigned to it throughout
the current execution of the run unit, unless an event that causes internal data items to
be reinitialized occurs. In that case, the data item is reassigned its initial value if it has
a VALUE clause or if a BLANK directive is active; if not, its contents are unpredictable.
Size Limits
In Section 20, HP COBOL Limits, see Data in a run unit.
Checkpointing
You do not have to put level-01 items (records) and level-77 items in any special order
in the Working-Storage Section; however, when you plan working storage for a
program to be run as a process pair, this approach simplifies checkpointing:
•
Group all independent data items into a record, and code the record in the same
part of the Working-Storage Section as other level-01 items.
•
Reserve level-77 items for constants, and code them last.