'preamble Dim Integer Flag 'Set a Flag Sub FlagSet(bit As Integer) FLAG=FLAG Or 1<<bit End Sub 'Clear a flag Sub FlagRes(bit As Integer) FLAG=(FLAG Or 1<<bit) Xor 1<<bit End Sub 'Equate a flag to a value Sub FlagEq(bit As Integer,v As Integer) If v Then FlagSet(bit) Else FlagRes(bit) Endif End Sub 'Test a flag Function FlagTest(bit As Integer) As Integer FlagTest=Abs(Sgn(FLAG And 1<<bit)) End Function 'Bitwise Invert, logical NOT 'For MMBasics without native Inv() Function Function Inv(a As Integer) Inv=a Xor &hFFFFFFFFFFFFFFFF End Function
'for CMM2 Sub FlagRes(bit As Integer) FLAG=FLAG And Inv(1<<bit) End Sub