SetBit
Sets a single bit in an Integer tag to 1.
Function | Group | Execution | Windows | Embedded | Thin Client | Mobile Access |
---|---|---|---|---|---|---|
SetBit | Arithmetic | Synchronous | Supported | Supported | Supported | Not supported |
Syntax
SetBit( tagName, numBitNumber )
- tagName
- The name of an Integer tag where the bit value will be set.
Note: To directly specify the name of a tag, rather than take the value of the tag, you must enclose the tag name in double-quotes. For example, SetBit( “Second”, 1 ).
- numBitNumber
- A numeric tag or value specifying the position (0…31) of the bit to set.
Returned value
0 | No error |
1 | Invalid parameter |
2 | Tag does not exist |
Notes
You can also use the Bit field to read/write values from specific bits of an integer tag. For example, enter Second->b0 to access the LSB (Least Significant Bit of the Second tag), and Second->b31 to access the MSB (Most Significant Bit of the Second tag).
Examples
Tag Name | Expression |
---|---|
Tag | GetBit( “numSource”, 4 ) // If the tag numSource held a value of 0, then this function returns 0 and numSource holds a new value of 16. |
Tag | GetBit( “numSource”, 1 ) // If the tag numSource held the value 17, then this function returns 0 and numSource holds a new value of 19. |