Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Subscripting

One method of specifying occurrence numbers is to append one or more subscripts to the data-name. A subscript is an integer whose value represents the occurrence number of a table element or one of the items subordinate to that table element. The subscript may be represented

  • by an integer literal

  • by a data-name defined as a numeric elementary data item without any character positions to the right of the assumed decimal point

  • by an arithmetic expression that is neither a direct nor a relative subscript.

In either case, the subscript must be enclosed in parentheses and must be written immediately following any qualification for the name of the table element. The referenced table element must have appended to it as many subscripts as the associated table has dimensions. A subscript must therefore be supplied for each OCCURS clause, including the OCCURS clause which contains the data-name within the defined hierarchy.

In example 2-13 in section "Table definition" (three-dimensional table), the following are required:

  • one subscript for references to BLK

  • two subscripts for references to RECORD

  • three subscripts for references to ITEM.

Subscripts are written proceeding from the outermost to the innermost table.

Thus, for example,

ITEM (1, 2, 2)

identifies the second element ITEM

within the second element RECORD

within the first element BLK.

A reference to a data item must not be subscripted unless the data item is a table element, or unless it is an item or condition-name within a table element.

There are three forms of subscripting:

  • direct subscripting

  • relative subscripting

  • subscripting by means of an arithmetic expression

Direct subscripting

With direct subscripting, the subscript is specified either by an integer literal or by a data-name. The data-name must be defined as a numeric elementary item with no character positions to the right of the assumed decimal point. In the preceding example, direct subscripting was used.

 

Relative subscripting

If the name of the table element is followed by a subscript in the form:

(data-name + integer-1),

then the occurrence number required to complete the reference is calculated from the value of data-name at object time, plus integer-1.

If it takes the form:

(data-name - integer-2),

the occurrence number is obtained by subtracting integer-2 from data-name.

Relative subscripting is treated in the same manner as relative indexing. For further details see section "Indexing".

Subscripting by means of an arithmetic expression

A subscript can consist of an arithmetic expression that supplies an integer as its result.

If a subscript consists of an arithmetic expression that is neither a direct nor a relative subscript, then the required occurrence number is calculated from the value of the arithmetic expression at object time.

At both compile time and object time, arithmetic expressions are processed more slowly than direct or relative subscripts. For this reason, swapping of data-name and integer in relative subscripts should be avoided, as too should the enclosure of a direct or relative subscript in parentheses since such expressions are considered to be arithmetic expressions.

If a subscript ends with a data-name or an index, then an immediately following subscript must not begin with a left parenthesis since this would initiate subscripting of the data-name or index.