index
The index function enables you to determine which instance of a particular loop the translator is currently accessing.
Common use
More often than not, variables are used to keep track of the current loop count instead of the function. The syntax states that you specify an integer variable for the parameter, but a constant is normally used instead of a variable. The index function can be used to determine if you are at a specific iteration of a group such as:
If index(2) = 1 then
…
Or
If index(1) = 10 then
…
The first example will check to see if the translator is at the first child group for the current parent. The second example will check to see if the translator is at the 10th iteration of the Parent group.
The Index function can also be used when using indexes to reference a field such as:
$SUB_GROUP[index(1)][index(2)][x].#FIELD = “TEXT”;This use would normally be used when you need to reference a repeating subgroup that is at the same level or a different branch of the group where the rule is written.
Syntax
index(integer_variable);where:
integer_variable= integer variable that indicates the hierarchical level for which you want to determine the loop count
Example
integer x;
x = index(1);
//This will populate x with the current loop count / iteration for the
//outer most parent group, from where the rule is written.
//The group will be located off of the root level of the map.
x = index(2);
//This will populate x with the current loop count / iteration for the
//first child group, from where the rule is written.
//The group will be a child to the parent group off the root level.
x = index(3);
//This will populate x with the current loop count / iteration for the
//first grandchild group, from where the rule is written.
//The group will be a grand child to the parent group off the root
//level, and a child to the first child group.