TOGGLE - Flip a boolean or a bit within a variable

Language reference ›› Built-in procedures ›› Bit management ››
Parent Previous Next

TOGGLE(<integer-variable>, <bit>) | TOGGLE(<integer-variable>.<bit-number-constant>)

Flip the given bit within <integer-variable>.


or:


TOGGLE(<boolean-variable>)

Flip the given boolean variable.


<integer-variable>:

Any integer variable or SFR.


<boolean-variable>:

Any boolean variable or bit within a variable or SFR.


<bit>:

A bit number constant 0..n applicable to <integer-variable>, or dynamic given by any expression.



VAR
 TheBit: BOOLEAN;
 TheWord: WORD;
 BitPos: BYTE;

 TOGGLE(TheBit);
 TOGGLE(TheWord, BitPos);