SIZE — Size In Elements
SIZE in rungs.dev counts the elements of an array and stores the count in a tag, so a rung never has to hardcode how long an array is.
SIZE
Array
array
Dimension
dimension
Destination
destination
Counts the elements of an array and stores the count in the destination tag.
What it does
SIZE keeps an array's length out of your logic. A rung written against a hardcoded 12
silently breaks the day someone resizes the tag to 20; a rung written against a SIZE result
keeps working.
It reads nothing from inside the array — only how long it was declared — so it never faults and never touches the data.
Operands
| Name | Type | Notes |
|---|---|---|
array | any array tag | The array itself — Samples or Samples[0] |
dimension | the number 0 | Which dimension to measure |
destination | DINT, INT, SINT, REAL | Where the count goes |
The whole array, not an element
Samples and Samples[0] both mean "the whole array". Samples[3] is refused — there is no
such thing as the size of a run starting part-way along. That is the opposite of
COP, where you must name one element.
dimension asks which dimension to measure. Studio supports
single-dimension arrays only, so it is always 0.
A narrow destination wraps like any other store: a 300-element array counted into a SINT
leaves 44, not 127.
Example — Loop to the End of the Array
0
Scan
SIZE
Array
Samples
Dimension
0
Destination
Count
1
LT
Source A
Index
Source B
Count
MoreToDo
Count always matches the array, so resizing Samples needs no change to the rung.
Structured Text
SIZE has a Structured Text form as well — see the
Structured Text SIZE page.
Related
- Array instructions overview
- Arrays — declaring one
- SIZE in Structured Text
FLL — Fill
FLL in rungs.dev writes one value into every element of a run of an array. Use it to clear a buffer, preset a recipe, or zero a structure in one rung.
AVE and STD — Average and Spread
AVE and STD in rungs.dev work out the average and the standard deviation of a run of array elements. Use them to smooth a noisy reading or to tell steady from unstable.