Skip to main content

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 of Sensors
  • Samples[3] — the fourth element of Samples
  • DelayTimer[2].PRE — the PRE member of the third TIMER in DelayTimer
  • Samples[i] — index with a DINT tag 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] when Samples has 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 raises Runtime error: Array index out of bounds and halts the scan.