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.
FLL
Source
source
Dest
dest
Length
length
Writes one value into every element of a run of an array.
What it does
FLL is the fast way to clear or preset a block of memory: zero a buffer before a new batch,
set every alarm limit to a default, blank a display array.
Like COP, it runs on every scan the rung is true — not once per rising edge.
Operands
| Name | Type | Notes |
|---|---|---|
source | DINT, INT, SINT, REAL | The value to write. A tag or a number |
dest | DINT, INT, SINT, REAL, STRING, TIMER, COUNTER, CONTROL | One element — where the run starts |
length | DINT, INT or SINT | How many elements to fill. A tag or a number |
length clamps to the destination, exactly as COP's does, and never faults.
Converting on the way in
For an ordinary array, the source is converted to the destination's type once, then written
into every element — the same rule MOVE uses.
| Source | Destination | Result | Why |
|---|---|---|---|
2.5 (REAL) | DINT[] | 2 | Halves round to even |
3.5 (REAL) | DINT[] | 4 | Halves round to even |
300 | SINT[] | 44 | Wrapped to 8 bits, not clipped |
70000 | INT[] | 4464 | Wrapped to 16 bits |
3.0e9 | DINT[] | -1294967296 | Wrapped to 32 bits |
This is conversion, not saturation: a value too big for the type wraps round rather than sticking at the maximum.
Filling a structure
A TIMER, COUNTER or CONTROL destination is different: the source's bytes are written
raw, with no conversion, over the whole structure — the numbers and the status bits alike.
A DINT or a REAL fills each 4-byte word; a SINT or an INT repeats its own 1 or 2 bytes,
so a SINT holding -2 fills every byte with the same pattern.
FLL(0, Dwell, 1) is the useful case: it zeroes the whole timer, preset included.
A STRING is filled the same way, over all of its bytes: FLL(0, Msg, 1) empties it and
clears every character. FLL(65, Msg, 1) does not fill it with As: 65 lands in .LEN
as well, and only every fourth character is an A. To fill a STRING with text, use
MOVE.
To fill only the characters, name the first one: FLL(0, Msg.DATA[0], 82) sets all 82 to 0
and leaves .LEN alone. Here each character is one SINT, so the value is converted, as it is
for any number array: FLL(65, Msg.DATA[0], 3) writes AAA. A length past the characters
runs on into the two spare bytes and stops at the end of the STRING, or of the whole array
when Msg is an element of one.
FLL(7, Dwell, 1) does not set the preset to 7 and stop there
It writes 7 into .PRE and .ACC, because both are words of the same structure. And a
value with a high bit set lands in the status bits too: FLL(2.5, Dwell, 1) writes the
decimal's bit pattern, which switches .TT on.
To set just one member, use MOVE: MOVE(5000, Dwell.PRE).
Example — Clear a Buffer
0
NewBatch
FLL
Source
0
Dest
Readings[0]
Length
20
1
NewBatch
FLL
Source
0
Dest
Total
Length
1
Structured Text
FLL has no Structured Text form. In a Structured Text routine, write a FOR loop, or use
COP with the replicate idiom.
Common Mistakes
- Using
FLLon a timer to set its preset. It fills every member. UseMOVE. - Expecting
300into aSINTarray to clip at127. It wraps to44. - Naming the bare array —
FLL(0, Readings, 20). Name an element:Readings[0].
Related
- Array instructions overview
- COP and CPS — copy a run instead of filling it
- MOVE — one value into one destination
COP and CPS — Copy
COP and CPS in rungs.dev copy a run of elements from one array into another. Use them to snapshot a buffer, replicate a value, or move a batch of readings in one rung.
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.