Arrays

To declare an array, use the DECLARE function. For complete information on the DECLARE function, see theEnrichment Language Reference Guide.

The elements of an array are referenced as varname[index]. For example, the elements of an array named %%AR are referenced as %%AR[0], %%AR[1], etc.

Array indexing is zero based. For example, if you declare an array with an array size of 5, valid indexes would be 0, 1, 2, 3, 4. Five would be out of bounds.

The following sample illustrates a basic array.
<input>
  <name> input 
  <file> input.txt
  <type> I
</input>
<rule>
<content>
  %%result = declare(%%arr, 'A' , 5)
   %%arr[0] = "apple"
   %%arr[1] = "banana"
   %%arr[2] = "orange"
   %%arr[3] = "pineapple"
   %%arr[4] = "watermelon"
   FOR %%i = 0 to arraysize(%%arr) -1
      write("result.txt", %%arr[%%i])
   NEXT %%i 
</content>
</rule>
<output>
  <name> output
  <file> output.txt
</output>