Code: Select all
mode.b + %0001 ; Print (yes)
mode.b + %0010 ; Suppress key value (yes)
mode.b + %0100 ; Totals only (yes)
Code: Select all
mode.b + %0001 ; Print (yes)
mode.b + %0010 ; Suppress key value (yes)
mode.b + %0100 ; Totals only (yes)
Code: Select all
Define mode.b
mode | %0001 ; Print (yes)
mode | %0010 ; Suppress key value (yes)
mode | %0100 ; Totals only (yes)
; Perform a binary AND with %010 to extract only bits in `mode` which match the ON (1) bits in %010.
If mode & %010
Debug "Suppress key value on!"
EndIf
Code: Select all
EnumerationBinary
#ModePrint
#ModeSuppressKeyValue
#ModeShowTotalsOnly
EndEnumeration
Thank you yuki that's great, very convenient to perform the check too. I like the setting of the mode with OR as you've done above.yuki wrote: ↑Sun Jan 29, 2023 7:21 am Classic bitmasking.Code: Select all
Define mode.b mode | %0001 ; Print (yes) mode | %0010 ; Suppress key value (yes) mode | %0100 ; Totals only (yes)
Glad to be of help!Oso wrote: ↑Sun Jan 29, 2023 7:33 amThank you yuki that's great, very convenient to perform the check too. I like the setting of the mode with OR as you've done above.yuki wrote: ↑Sun Jan 29, 2023 7:21 am Classic bitmasking.Code: Select all
Define mode.b mode | %0001 ; Print (yes) mode | %0010 ; Suppress key value (yes) mode | %0100 ; Totals only (yes)
Code: Select all
mode + #ModePrint + #ModePrint + #ModeSuppressKeyValue
Code: Select all
Macro IsBitNoXSet(Value, Bit)
Bool(Value & (1 << Bit))
EndMacro
Macro IsBitMaskBitSet(Value, Mask)
Bool(Value & Mask)
EndMacro
Define.u Word
Word = %1001000100100100
Debug IsBitNoXSet(Word, 0)
Debug IsBitNoXSet(Word, 2)
If IsBitNoXSet(Word, 14)
Debug "Bit 14 is set"
Else
Debug "Bit 14 is not set"
EndIf
If IsBitNoXSet(Word, 15)
Debug "Bit 15 is set"
Else
Debug "Bit 15 is not set"
EndIf
If IsBitMaskBitSet(Word, %0100000000000000)
Debug "Bit 14 is set"
Else
Debug "Bit 14 is not set"
EndIf
If IsBitMaskBitSet(Word, %1000000000000000)
Debug "Bit 15 is set"
Else
Debug "Bit 15 is not set"
EndIf
Thanks infratec, I experimented for at least a couple of hours with a bit shift as you've done before even posting the question on the forum yesterday but there had been a bug in my testing, leading me to conclude that it couldn't be done this way. The bug was that I was assuming the first bit was bit 1, rather than bit 0, so my results were unpredictable. Thanks for sending this.infratec wrote: ↑Sun Jan 29, 2023 9:59 am Thre are several examples in Tips 'n' Tricks. You can also use a Macro:Code: Select all
Macro IsBitNoXSet(Value, Bit) Bool(Value & (1 << Bit)) EndMacro
Code: Select all
This should be the result:
Debug Bool(12 & 1) => #False
Debug Bool(12 & 2) => #False
Debug Bool(12 & 4) => #True
Debug Bool(12 & 8) => #True
Debug Bool(12 & 16) => #False
Code: Select all
[Save_Changes_To_Disk]
2 = Catalog
1 = Configuration
2048 = Favorites
32 = Folder View Settings
8 = Keyboard Shortcuts
4096 = Tabs
64 = Tags
4 = User-Defined Commands