Arrays
An array is an indexed list of values. For example, if you have an array named %%myArray
with values 23, 12, and 65, you could reference these values as follows:
%%myArray[0] would return 23
%%myArray[1] would return 12
%%myArray[2] would return 65
This array has a size of three meaning that there are three values in the array. The size of an array is specified when it is declared which is accomplished through the DECLARE function. For more information on this function, see the EngageOne™ Enrichment Language Reference Guide.
When you use an array in an assignment, certain rules apply:
- If you use an array on the left side of an assignment, you will set the value of all elements of the array. For example:
%%myArray = 33
will set all elements of the array to 33.
However, the following:
%%myArray[2] = 33
will set the 3rd element of the array to 33.
- You cannot use an array on the right side of an assignment unless you use the DECLARE or ARRAYSIZE functions. For example, the following statements are valid:
%%someValue = DECLARE(%%myarray, 'A', 3)
%%anotherValue = ARRAYSIZE(%%myArray)