Skip to content

CLR — Clear

Category
Compute
Type
Output
Availability
All platforms

CLR instruction block: Dest Total


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.


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.


Nothing. Dest keeps its power-up value.

The instruction does nothing. Dest holds its last value.

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.

Nothing.


Scenario: The combined count from the ADD example is zeroed at the start of each shift.

Tags:

  • Reset_Total — Shift start, BOOL
  • Total — 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.

Figure 1 — CLR rung false: Total 65, rung dark

Scan 2 — Reset_Total = 1. Total reads 0.

Figure 2 — CLR rung true: Total reads 0, rung lit

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.


  • 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