GetBit

GetBit is a built-in scripting function that gets the value of a single bit in a numeric value.

Function Group Execution Windows Embedded Thin Client Mobile Access
GetBit Arithmetic Synchronous Supported Supported Supported Not supported

Syntax

  GetBit( tagName, numBitNumber )  
tagName
The name of an Integer tag from which the bit value will be gotten.
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, GetBit( “Second”, 1 ).
numBitNumber
A numeric tag or value specifying the position (0…31) of the bit to get.

Returned value

Returns the value ( 0 or 1 ) of the specified bit.

Notes

You also can use the Bit field to read/write values from specific bits in 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 holds a value of 15, then this function returns 0.
Tag GetBit( “numSource”, 1 ) // If the tag numSource holds a value of 19, then this function returns 1.

GetBit