GetBit - Manual - SIMATIC AX - System BitAccess Library - System.BitAccess,library

System.BitAccess library

Portfolio
SIMATIC AX
Product
SIMATIC AX
Software version
7.1.47
Edition
05/2024
Language
English (original)
Package Name
@ax/system-bitaccess

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 LWORD
When 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