CLR — Clear

Description
Section titled “Description”CLR (Clear) writes zero to Dest every scan its rung is true. It is an output instruction with a single operand, no state and no status bits. Use CLR to zero a running total, a shift-register word, or a fault code at the start of a cycle; on a STRING it empties the text. Do not use CLR on a timer or counter to reset it; that is what RES is for, and CLR on a struct is not accepted.
Operands
Section titled “Operands”| Operand | Type | Format | Valid Range | Required | Description |
|---|---|---|---|---|---|
| Dest | A writable tag, member or element | Tag, Tag.Member, Tag[n] |
SINT, INT, DINT, REAL, STRING or a BOOL; not a literal, not an input pin | Yes | The value to zero. |
A REAL Dest becomes 0.0, a STRING Dest becomes the empty string, a BOOL Dest becomes 0. A timer or counter member such as Batch.ACC is a valid Dest; the whole struct is not.
Scan Behavior
Section titled “Scan Behavior”Prescan
Section titled “Prescan”Nothing. Dest keeps its power-up value.
Rung-condition-in is false
Section titled “Rung-condition-in is false”The instruction does nothing. Dest holds its last value.
Rung-condition-in is true
Section titled “Rung-condition-in is true”Zero is written to Dest every scan the rung is true. Anything else writing Dest on a later rung in the same scan wins, because rungs execute in order.
Postscan
Section titled “Postscan”Nothing.
Example
Section titled “Example”Scenario: The combined count from the ADD example is zeroed at the start of each shift.
Tags:
Reset_Total— Shift start, BOOLTotal— Combined count, INT
Rung 1:
—] [Reset_Total———[CLR Total]———Scan 1 — Reset_Total = 0. Total reads 65 from the previous shift. The rung is false: nothing changes.

Scan 2 — Reset_Total = 1. Total reads 0.

If Reset_Total is a pushbutton held for a second, the CLR runs for the whole second. That is harmless here, but a CLR on a value another rung is accumulating will fight it; put an ONS on the button.
See Also
Section titled “See Also”- MOV — Move (write any value, not only zero)
- RES — Reset (zero a timer or counter properly)
- ADD — Add (the running sum this example clears)
- Compute Instructions — Category index
Clearing a member. CLR Batch.ACC zeroes the accumulator but leaves DN as it was. RES clears the accumulator and the status bits together.
Clearing a STRING. The text becomes empty, length zero. Compare with EQU Msg "" to detect it.
The block never colours. Watch the rung wire and the Dest value line.
Applies to LadderIDE >=1.2.2 · Last reviewed 2026-09-11 · Screenshots verified 2026-09-11