Arrays
- Last UpdatedJul 26, 2020
- 2 minute read
Arrays are a collection of variables under a single name, ordered by a numeric index. Arrays can be one dimensional or two dimensional, with each dimension value separated by comma, if necessary.
Arrays are referenced as a whole, using the array item syntax, or by individual element. If the whole array is requested, the length of the requested data from the array must not exceed the maximum PDU size limit (2000 bytes).
Array Item Syntax
#<PLCVariableName> ARRAY(<DatatypeSuffix>)
Where <DatatypeSuffix> is one of these suffixes: BT, S, W, L, DW, BY, F, LF, M.
The array may be passed to the variable as a series of values separated by spaces, tabs or carriage return/line feeds. It will be returned by the PLC as a series of value separated by carriage returns/line feeds.
To poke new values to the array, you cannot poke a partial array, but must write the full length array string.
Important: Array and symbolic variable addressing is only supported in subscribing data from the PAC Rx3i and PAC Rx7i controllers. Because of protocol limitations, array or symbolic variable addressing is not supported from other GE controllers.
For example, if the original array value was "1 2 3 4 5" and you needed to replace the "3 4" with "6 7," you would need to poke "1 2 6 7 5."
Examples:
#TankArray ARRAY(L)
This creates an array named "TankArray," with the canonical data type of VT_I4 (4 byte integer).
#R3000 ARRAY(W)
This creates a symbolic variable named "R3000," with the canonical data type of VT_UI2 (2 byte unsigned integer).
Array Element Item Syntax
#<PLCVariableName>[n] <ItemSuffix>
Where n is the element number from the array.
Examples:
#TankArray[2] L
This creates array item 2 in the array "TankArray," which has the canonical data type of VT_I4 (4 byte integer).
#R3000[2,3] W
This creates an array item in row 2, column 3 of the two-dimensional array "R3000," which has the canonical data type of VT_UI2 (2 byte unsigned integer).