Ive got to the bottom of it. Band isnt working properly, but I dont know how to proceed.
So tldr
Band is returning a value for an equate that hasnt been placed in the bitmask var.
Consequently Im getting different values returned by band.
Eg
Eq1 equate(0001b)
Eq2 equate(0010b)
Eq3 equate(0011b)
Bm long
Rv long
Bm = bor(bm,Eq1)
Rv = band(bm,eq2)
Rv = band(bm,eq3)
Rv contains the value for Eq1 when Im expecting it to be zero.
Bor and bxor are adding and subtracting nicely as expected, bshift is working as expected
Eg I have 21 bitmasks so I shift them -21 to see if there is any value using the 22nd or more bits as another check, but I simply was not expecting band to return a value only a zero.
This is also why I thought I could use case band(bm,eq3) as a sort of range check.
Edit.
The quick fix is to qualify the if statement better because that only wants a zero as false and all other values positive or negative as a true, so
If band(bm,eq3) = eq3
Would fix the problem but Im thinking something like
bEqual procedure(**? var, ? bitmask),byte
Code
Return choose((band(var,bitmask) = bitmask),1,0)
Would avoid future mistakes as an off the top of my head example.
Edit2
So the bequal example works perfectly as expected.
So simple, and whilst it can be used in a case statement as its returning true or false there is no point when looking at how much more code has to be written compared to an if statement.
If bequal(var,bitmask)
! True
Else
! False
End
Case bequal(var,bitmask)
Of bequal(var,bitmask)
Orof true
! Do something
Of not bequal(var,bitmask)
Orof false
! Do something else
Else
! Month of Sundays
End
That code example for band in the help docs, it isnt the best and band isnt but is the best function for testing for bitmasks provided they have an = requiredbitmask to qualify it with.