Hemi345
Senior Member
I'm storing some statuses as bits in byte b3. Quite a few of these are configured the same way, so if I determine which menu option I'm currently on, I can toggle on/off the corresponding bit. Is there a way to dynamically reference a bit? I think there's gotta be a way to make the following IF statement more efficient.
Is there a clever way to toggle the bits using something like the following example to make it more concise and dynamic?
Code:
symbol cREa = 32 'anti-clockwise rotation of encoder
symbol cREc = 64 'clockwise rotation
symbol cREi = 96 'idle, no rotation
symbol vMenuOption = b0
symbol bMenuChoose = bit24 'in b3
symbol bNeedTune = bit25 'in b3
symbol bAlarm1stat = bit26 'in b3
symbol bAlarm2stat = bit27 'in b3
if vMenuOption = 1 AND vStatus = cREa then 'AW
bAlarm1stat = cOff
else if vMenuOption = 1 AND vStatus = cREc then 'CW
bAlarm1stat = cOn
else if vMenuOption = 2 AND vStatus = cREa then 'AW
bAlarm2stat = cOff
else if vMenuOption = 2 AND vStatus = cREc then 'CW
bAlarm2stat = cOn
end if
Code:
bptr = vMenuOption + 60
if vStatus = cREa then
@bptr = cOff
else if vStatus = cREc then
@bptr = cOn
end if