Comparison of index-names and index data items

Comparisons involving index-names, index data items, or both conform to rules.

The rules for comparisons are:

  • The comparison of two index-names is actually the comparison of the corresponding occurrence numbers.
  • In the comparison of an index-name with a data item (other than an index data item), or in the comparison of an index-name with a literal, the occurrence number that corresponds to the value of the index-name is compared with the data item or literal.
  • In the comparison of an index-name with an arithmetic expression, the occurrence number that corresponds to the value of the index-name is compared with the arithmetic expression.

    Because an integer function can be used wherever an arithmetic expression can be used, you can compare an index-name to an integer or numeric function.

  • In the comparison of an index data item with an index-name or another index data item, the actual values are compared without conversion. Results of any other comparison involving an index data item are undefined.

Valid comparisons for index-names and index data items are shown in the following table.

Table 1. Comparisons for index-names and index data items
Operands compared Index-name Index data item Data-name (numeric integer only) Literal (numeric integer only) Arithmetic Expression
Index-name Compare occurrence number Compare without conversion Compare occurrence number with content of referenced data item Compare occurrence number with literal Compare occurrence number with arithmetic expression
Index data item Compare without conversion Compare without conversion Invalid Invalid Invalid