Subscripts can be used only when reference is made to an individual element within a list or table of like elements that have not been assigned individual data-names (see the topic The OCCURS Clause).
The subscript can be represented either by a numeric literal that is an integer, by a data-name, or by a data-name followed by the operator "+" or "-" , followed by an unsigned integer numeric literal. The data-name must be a numeric elementary item that represents an integer, and the whole subscript must be delimited by the balanced pair of separators, left-parenthesis and right-parenthesis.
The subscript data-name can be signed and, if signed, must be positive. The lowest possible subscript value is 1. This value points to the first element of the table. The next sequential elements of the table are pointed to by subscripts whose values are 2, 3, ... . The highest permissible subscript value, in any particular case, is the maximum number of occurrences of the item as specified in the OCCURS clause.
The subscript, or set of subscripts, that identifies the table element is delimited by the balanced pair of separators, left parenthesis and right parenthesis following the table element data-name. The table element data-name appended with a subscript is called a subscripted data-name or an identifier. When more than one subscript is required, they are written in the order of successively less inclusive dimensions of the data organization. Up to 3 subscripts are permitted.
Up to 7 subscripts are permitted.
Up to 16 subscripts are permitted.
An index described for some other table can be used instead, provided the two tables have elements of the same size.
The mixing of subscripts and indices in the same identifier is legal.
If the subscript is a floating-point data item, the value is rounded to the nearest integer, otherwise any fractional part is truncated.
If arithmetic-expression-1 is specified, and the final result of the arithmetic expression is not an integer, the final result is truncated. Intermediate results are not truncated.
If arithmetic-expression-1 is specified, and if the final result or any intermediate result of the arithmetic expression is negative, the effect is unpredictable.
integer-3 is specified, the value of the subscript is determined by incrementing by the value of
integer-3 (when the operator "+" is used) or by decrementing by the value of
integer-3 (when the operator "-" is used),
the occurrence number represented by the value of the index referenced by index-name-1
or the value of the data item referenced by data-name-2
If the NOBOUND Compiler directive is specified, the General Rules are not applicable at run time.