INDEX

You can use the INDEX function when you need to select or test particular objects based on their occurrence, or to add a sequence number to output objects.

INDEX returns an integer that represents the index of an object relative to its nearest contained object, counting only valid objects.

INDEX cannot be used in a component rule.

Syntax:
INDEX (single-object-name)
Meaning:
INDEX (object_for_which_to_get_index)
Returns:
A single integer

The object_for_which_to_get_index variable must be a type name. The result is the index of object_for_which_to_get_index.

  • If object_for_which_to_get_index is an input, this will be the index within all valid objects.
  • If object_for_which_to_get_index is an output, this will be the index within all objects (valid and invalid).
  • Returns 0 if the input argument is "none".

    The difference between INDEXABS and INDEX is that INDEXABS counts both valid and invalid instances, whereas INDEX counts only valid instances.

Examples

  • Message (s) = IF (INDEX (Message:Input) > 3, Message:Input, "none")

    For example, there are five Messages in Input. The first three evaluations of this rule return "none". The fourth evaluation returns Message[4]. The fifth evaluation returns Message[5].

  • Invoice (s) = MyMap (Invoice Segment:Input, INDEX ($))

    For the first evaluation of MyMap, INDEX($) is 1. For the second evaluation of MyMap, INDEX($) is 2.

Related functions

  • CHOOSE
  • COUNT
  • COUNTABS
  • INDEXABS