Pathway/iTS SCREEN COBOL Reference Manual (G06.24+, H06.03+, Pathway/iTS 1.0+)

SCREEN COBOL Source Program
Compaq NonStop™ Pathway/iTS SCREEN COBOL Reference Manual426750-001
2-27
Subscripting
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.
The receiving data in the example is undefined because the left or right byte of a double-
byte character has no meaning.
{ data-name } ( sub-1 [ , sub-2 [ , sub-3 ] ] )
{ condition-name }
Note. Arrays defined using a PIC N clause are referenced in units of two bytes.