Set Bit

The Set Bit action sets the value of a bit in a variable.


Input tab

Parameter Description
Input Value The name of the source variable whose bit you want to set.
The input variable can be of any data type. However, a STRING variable should not be used as the length of the string is embedded in the first 4 bytes.
The result of the Set Bit action is copied from the internal replica of the source variable to the destination array.
If you want to update a source varaiable directly with the bit value specified, then the Output tabOutput Value parameter should be set to the same device variable as the Input tab Input Value parameter.
Bit Number The position of the bit in the input variable, where 0 is the low-order bit position.
Bit Value The value to set into the bit at position Bit Number. This can be a any type of variable.
For a Constant:
  • True or 1 = Set the bit to 1 (on) .
  • False or 0 = Set the bit to 0 (off).

Output tab

The Output tab provides the means to set one bit in an integer. You can only set one bit per Set Bit action.


The Output tab provides three rows to set values for Set Bit.

Parameter Description
Output Value Specifies the destination variable to place the result of the Set Bit action.
The result of the Set Bit action is copied from the internal replica of the source variable to the destination array.
If you want to update a source variable directly with the bit value specified, then the Output tab Output Value parameter should be set to the same device variable as the Input tabInput Value parameter.

Example Set Bit

You can use the Set Bit action in a trigger to set a bit in an integer variable (such as INT2). Since an INT2 (or WORD) represents a 2-byte data field, bit 0 always represents the least significant bit, and bit 15 represents the most significant bit.

The example Input tab shows how to set bit number zero in D[10] to the value one.


The Output tab is used to store the result of this action.


Note that the other bits in D[10] are not affected by this operation. They retain their values from before the action. In other words, bits 1 through 15 remain unchanged.