Gets the value of the specified bit of a bit string.
Parameters:
| Name | Type | Section | Description |
|---|---|---|---|
| value | T | Input | The bit string on which to operate. |
| index | USINT |
Input | Represents the position of the bit to get. The valid range depends on the type of the value-variable:- [0..7] for BYTE- [0..15] for WORD- [0..31] for DWORD- [0..63] for LWORDWhen specifying an invalid index the function returns FALSE. |
BOOL |
Return value | Provides the value of the specified bit. |
The type T may be any of BYTE, WORD, DWORD or LWORD.
Example:
USING System.BitAccess;
PROGRAM GetBitProgram
VAR
value : WORD;
bitValue : BOOL;
END_VAR
// return the value of the bit at index 3
// 0000_0000_0000_->1<-000
bitValue := GetBit(value, USINT#3);
END_PROGRAM