Write Tag Bit

Write Tag Bit is a click behavior in the Interactions category: when the user clicks the shape on the exported page, it changes only one bit inside an integer tag and leaves the other bits untouched. It fits the common case where one integer register packs several on/off bits. You do not read the integer, build a mask, and write it back yourself; the behavior does it for you: read the current integer, build a mask from the bit index, apply Set / Reset / Toggle, then write the new integer through the same host write path. The difference from Write Tag is that Write Tag writes a whole tag value, while Write Tag Bit moves only a single bit. It runs only on real user interaction.

Interactions

Interactions: Write Tag Bit

On click, flips just one bit of an integer tag (Set / Reset / Toggle), leaving the other bits unchanged; the write still goes through the host's unified write path.

What it is and what it is for

Write Tag Bit is a click behavior in the Interactions category: when the user clicks the shape on the exported page, it changes only one bit inside an integer tag and leaves the other bits untouched. It fits the common case where one integer register packs several on/off bits. You do not read the integer, build a mask, and write it back yourself; the behavior does it for you: read the current integer, build a mask from the bit index, apply Set / Reset / Toggle, then write the new integer through the same host write path. The difference from Write Tag is that Write Tag writes a whole tag value, while Write Tag Bit moves only a single bit. It runs only on real user interaction.

How to use it: the editor fields

After you add Write Tag Bit to a shape, the editor opens in three groups: General, Interaction Setup, and Options. Fill them in:

  • Behavior Name: a label for this behavior so you can recognize it later.
  • Component Name: the current shape name; read-only, cannot be edited.
  • Setup Script (Definition): optional. Prepare variables or helper logic here, or leave it empty.
  • Tag: the target tag to write; enter the parent integer tag that holds the bits; do not add a bit subscript here. A plain tag name needs no quotes; use expression form for a variable.
  • Bit Index: which bit to change, 0-31. Bit 0 is the least significant (right-most) bit.
  • Bit Action: Set (force to 1) / Reset (force to 0) / Toggle (flip 0 and 1); pick one.
  • Use FORCE mode: when checked, this write is sent in force mode; leave it off if unsure.
  • Condition (Enabled): acts as a gate; runs the action when it evaluates to true, skips this click when false.
  • Options: Show hand cursor when enabled, Use bold border when enabled, Hide when disabled.
Tag:        PLC1.PUMP.CTRL_WORD
Bit Index:  3
Bit Action: Toggle
Condition:  ReadTagBoolean("PLC1.PUMP.REMOTE", false)

When to use it

Typical case: one control-word integer packs several command bits.

  • Start/Stop button: use Toggle to flip the run bit in the control word, so one button starts and stops it.
  • Reset an alarm-acknowledge bit: use Reset to clear a bit, or use Set to raise an enable bit to 1.
  • When you need to gate the click, put a check in Condition (e.g. only allow the flip in remote mode).

Boundaries and common mistakes

A few easy traps:

  • Tag must be the parent integer tag that holds the bits; do not append [bit] to the tag name. The bit is set separately by Bit Index (the [0..31] subscript form is for reads, not bit writes).
  • Bits are zero-based and Bit 0 is the least significant bit; the range is 0-31, so do not think of it as 'bit 1'.
  • A write is not guaranteed to be immediate: the host may add permission checks, confirmation, reason input, or async processing, so never assume 'clicked means succeeded and synchronous'.
  • An empty Condition is treated as true (the action runs).
Write Tag Bit behavior editor
Figure 1: Write Tag Bit editor

Pick the parent integer tag and Bit Index, then Set / Reset / Toggle just that one bit, leaving the others unchanged.