Subscripting

Subscripting is used when reference is made to an individual element of a table.

General Format

{data-name     }  ( { index-val [ {+} integer  ] } ...)
{condition-name}                  {-}

Syntax Rules

  1. index-val must be either an integer literal, an integer elementary data item, or an index name. It may be qualified.
  2. data-name and condition-name must be subordinate to an OCCURS clause.
  3. integer must be an integer literal.
  4. The number of subscripts must equal the number of OCCURS clauses in the description of the table element being referenced. When more than one subscript is required, they are written in the order of successively less inclusive dimensions of the table.
  5. If both qualification and subscripting of a data name are being used, the qualification is done first.
  6. If both subscripting and reference modification of a data name are being used, the subscripting is done first.

General Rules

  1. The value of the subscript must be a positive integer. The lowest occurrence value is represented by the value 1. Each successive element of a table within a dimension is referenced by occurrence numbers of 2, 3, 4, and so on. The highest permissible occurrence number for any given dimension of a table is the maximum number of occurrences of the item as specified by the associated OCCURS clause.
  2. If integer is specified, the value of the subscript is determined by adding or subtracting the integer from index-val. This modified value is subject to all of the conditions of rule 1 above.
  3. By default, it is not an error to reference a table element beyond the last one in the table, but the results are undefined and may adversely affect your program. In fact, this is the single most frequent cause of memory access violation errors. Use the -Za compiler option to cause an error message to display whenever an out-of-bounds table element is referenced. The error text is: Index out of bounds. This error is an intermediate runtime error that can trigger the execution of installed error procedures.