Special usage of bit number or reference

Language reference ›› Variables ››
Parent Previous Next

PMP's special (not standard Pascal): bits within an identifier may be referenced with their bit number, numerical or constant.



CONST
 TheBit = 5;
VAR
 ABit: boolean;

 Abit := _MyVar.4;
 ABit := TheVar.TheBit;
 ABit := PORTA.0;


PMP's special (not standard Pascal): when referenced in a "set" or "dot" syntax, boolean variables return their bit number; this is useful for I/O mappings.



VAR
 MyInput1: boolean @ PORTA.3;
 MyInput2: boolean @ PORTA.4;

 TRISA := [MyInput1, MyInput2]; // Equivalent to [3, 4]
 TRISA.MyInput1 := TRUE;        // Set TRISA.3 to 1