Handling tables 4.3 accessing table elements, 3 subscripting with data names – Compaq COBOL AAQ2G1FTK User Manual

Page 136

Advertising
background image

Handling Tables
4.3 Accessing Table Elements

Note

Because ITEM5 is not subordinate to ITEM2, an occurrence number for
ITEM2 is not permitted in the subscript list (when referencing ITEM3,
ITEM4, or ITEM5). The ninth occurrence of ITEM2 in the fifth occurrence
of A-GROUP will be selected by ITEM2(5,9).

Table 4–1 shows the subscripting rules that apply to Example 4–16.

Table 4–1 Subscripting Rules for a Multidimensional Table

Name of Item

Number of Subscripts
Required to Refer to
the Name Item

Size of Item in Bytes
(Each Occurrence)

A-TABLE

NONE

1105

A-GROUP

ONE

221

ITEM1

ONE

1

ITEM2

TWO

2

ITEM3

TWO

9

ITEM4

TWO

1

ITEM5

THREE

2

4.3.3 Subscripting with Data Names

You can also use data names to specify subscripts. To use a data name as a
subscript, define it with COMP, COMP-1, COMP-2, COMP-3, or DISPLAY usage
and with a numeric integer value. If the data name is signed, the sign must be
positive at the time the data name is used as a subscript.

A data name that is a subscript can also be subscripted; for example, A(B(C)).
Note that for efficiency your subscripts should be S9(5) to S9(9) COMP.

Advertising