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

condition-name
is a level-88 item associated with either a data item described with an OCCURS clause or a
data item subordinate to a data item described with an OCCURS clause. If condition-name
is qualified, the subscripts follow the qualifiers.
subscript
integer
is a nonzero numeric literal. If it is signed, the sign must be positive.
qualified-name
is the identifier of an integer numeric data item. It can be qualified, but cannot have subscripts
or reference modifiers.
index-name
is the index in the INDEXED phrase of the OCCURS clause that describes data-name. Its
value is the occurrence number of an element in the associated table. The program must initialize
the value of an index-name before using it in a subscript.
offset
is an unsigned integer numeric literal. Its value is added to (+) or subtracted from (-) the value
of qualified-name or index-name.
Example 18 shows subscripting for two 1-dimensional tables and a 2-dimensional table.
Example 18 Subscripting for Tables
MOVE TOTAL OF REPORT-MARK (8) TO REPORT-TOTAL-8.
MOVE MONTH-NAME (MONTH-NUMBER + 2) TO REPORT-MONTH.
MOVE MATRIX (ROW COLUMN) TO OUTPUT-DISPLAY-LINE.
Number and Range of Subscripts
HP COBOL supports subscripting of up to 7 dimensions.
The lowest legitimate subscript value is 1, which selects the first element of a table. The next
sequential elements of the table are selected by subscripts whose values are 2, 3, and so on. The
highest subscript value, in any particular case, is the maximum number of elements in the table.
Any higher subscript is erroneous, and can cause an error.
You can use the directive CHECK (page 541), with a level-number greater than 1, to include code
in the resulting program to perform range checking during execution. If the program attempts to
use a subscript that is out of range, the range checking routine reports a fatal error.
If you do not include a CHECK directive, the compilation produces a program in which
subscript-out-of-range errors go undetected. These undetected errors can cause corruption of other
data, producing errors that can be difficult to locate, even with a symbolic debugger.
Reference Modifiers
Reference modifiers allow you to reference an arbitrary portion of a data item’s value, which is
important in some applications. With reference modifiers, you define an elementary item by
specifying a leftmost character position within a data item and a length for the new item. The
unique data item created by reference modifiers can be used not only as a sending item, but also
as a receiving item—you can store a new value into it.
References to Data Items 91