Array Tags
An array tag holds a list of values of the same data type under a single name. Reference an element with Tag[index].
Creating an array
In the tag editor, create a tag with usage Local and set its array size to a positive number. Rungs stores the elements as Tag[0], Tag[1], …, Tag[size - 1].
Every data type can be an array element — BOOL, DINT, REAL, TIMER, COUNTER, FBD_TIMER, FBD_COUNTER. For example, DelayTimer with size 12 gives you 12 independent TIMER structures reachable as DelayTimer[0].PRE, DelayTimer[0].DN, DelayTimer[1].PRE, …
Referencing an element
Use Tag[index] anywhere a tag name is accepted — instruction operands, expressions, comparisons:
Sensors[0]— the first element ofSensorsSamples[3]— the fourth element ofSamplesDelayTimer[2].PRE— thePREmember of the thirdTIMERinDelayTimerSamples[i]— index with aDINTtag to read or write the element at runtime
In Ladder Logic, array references drop directly into instruction operands:
XIC(Sensors[0])GT(Samples[3],100)OTE(Alarm)
Every reference must include an integer or integer tag in square brackets. Missing the index on an array tag produces:
Tag 'Samples' is an array and requires an index, use Samples[0]
Using an index on a scalar (non-array) tag produces:
Tag 'Count' is not an array and cannot be indexed
Restrictions
- Single-dimension only. Multi-dimensional arrays (
Tag[row][col]) are not supported. - Local usage only. Input and Output tags cannot be arrays — set usage to Local.
- Indices must be in range. Writing
Samples[5]whenSampleshas only 3 elements is a compile-time error. If the index is itself a tag (Samples[i]), the compiler cannot check it — an out-of-range access at runtime raisesRuntime error: Array index out of boundsand halts the scan.