Pathway/iTS SCREEN COBOL Reference Manual (H06.10+, J06.03+)

SCREEN COBOL Source Program
HP NonStop Pathway/iTS SCREEN COBOL Reference Manual426750-003
2-27
Subscripting
Subscripting
Subscripts are used to reference elements in a table. They are needed because all
table elements have the same name.
The subscript can be an integer numeric literal or a data item that represents a numeric
integer. When the subscript is a data item, the data item name can be qualified but not
subscripted itself. The subscript can be signed and, if signed, it must be positive.
The lowest possible subscript value is 1. This value selects the first element of a table.
The other elements of the table are selected by subscripts whose values are 2, 3, 4,
and so forth. If a subscript value greater than the size of the table is used, the result is
undefined.
The subscript, or set of subscripts, is enclosed in parentheses and is appended to the
element name of the table. When more than one subscript is required, they are written
in the order of most significant value to least significant value.
Subscript syntax is:
Note that a multiple-subscripted data item must have a space character preceding all
subscripts except the first.
The following examples illustrate subscripting:
MOVE total(8) TO report-total-8.
MOVE day of date(3) TO print-line-date.
MOVE month-name(month-number) TO report-month.
MOVE matrix(row, column) TO output-display-line.
Referencing a subscripted data item defined using a PIC X(n) clause (where n is an
integer from 1 through 32,000) containing double-byte data redefined as PIC X(1)
OCCURS n TIMES might reference only the left or right byte of a double-byte
character. The left or right byte of a double-byte character by itself has no meaning
and therefore the byte is undefined. For example:
WORKING-STORAGE SECTION.
:
01 WS-KANJI-DATA PIC N(05).
01 WS-UNDEFINED-DATA PIC X.
01 WS-NAME-1 PIC N(05).
01 WS-GROUP-REDEF REDEFINES WS-NAME-1.
02 WS-BYTE-DATA PIC X OCCURS 10 TIMES.
:
:
PROCEDURE DIVISION.
:
:
MOVE WS-KANJI-DATA TO WS-NAME-1.
MOVE WS-BYTE-DATA(1) TO WS-UNDEFINED-DATA.
{
data-name
} (
sub-1
[ ,
sub-2
[ ,
sub-3
] ] )
{
condition-name
}