You can specify dimension(s) for internal variables, in order to declare arrays. All indexes are 0 based. For instance, in case of single dimension array, the first element is always identified by ArrayName[0].
To declare an array, enter its dimension in the corresponding column of the variable editor. For a multi-dimension array, enter dimensions separated by comas (ex: 2,10,4).
Use in ST and IL languages:
To specify an item of an array in ST and IL language, enter the mane of the array followed by the index(es) entered between "[" and "]" characters. For multi-dimension arrays, enter indexes separated by comas. Indexes may be either constant or complex expressions. Below are some examples in ST language:
TheArray[1,7] := value;
result := SingleArray[i + 2];
Use in FBD and LD languages:
In graphical languages, the following blocks are available for managing array elements:
[I]>> | get value of an item in a single dimension array |
[I,J]>> | get value of an item in a two dimension array |
[I,J,K]>> | get value of an item in a three dimension array |
>>[I] | set value of an item in a single dimension array |
>>[I,J] | set value of an item in a two dimension array |
>>[I,J,K] | set value of an item in a three dimension array |
For "get" blocks, the first input is the array and the output is the value of the item. Other inputs are indexes in the array.
For "put" blocks, the first input is the forced value and the second input is the array. Other inputs are indexes in the array.
Restrictions:
- Arrays have at most 3 dimensions.
- All indexes are 0 based.
- The total number of items in an array (merging all dimensions)
cannot exceed 65535.