Addressing bits in variables
In integer variables, individual bits can be accessed. For this, the index of the bit to be addressed is appended to the variable, separated by a dot. The bit-index can be given by any constant. Indexing is 0-based.
Example:
a : INT;
b : BOOL;
...
a.2 := b;
The third bit of the variable a will be set to the value of the variable b.
If the index is greater than the bit width of the variable, the following error message is issued: Index '<n>' outside the valid range for variable '<var>'!
Bit addressing is possible with the following variable types: SINT, INT, DINT, USINT, UINT, UDINT, BYTE, WORD, DWORD.
If the variable type does not allow it, the following error message is issued: „Invalid data type '<type>' for direct indexing“
A bit access must not be assigned to a VAR_IN_OUT variable!