Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Michael Vogel
Addict
Posts: 2797 Joined: Thu Feb 09, 2006 11:27 pm
Contact:
Post
by Michael Vogel » Tue Jun 28, 2016 7:51 am
Code: Select all
EnumerationBinary ;#Null
;#STPF_NONE=0
#STPF_USEAPPTHUMBNAILALWAYS
#STPF_USEAPPTHUMBNAILWHENACTIVE
#STPF_USEAPPPEEKALWAYS
#STPF_USEAPPPEEKWHENACTIVE
EndEnumeration
Debug #STPF_USEAPPPEEKWHENACTIVE
I'd like to be able to start enumerate binary flags starting from 0.
Removing one of the commented parts in the code example above shows that this can't be done.
My Workaround:
Code: Select all
Macro BinaryEnumeration
((#PB_Compiler_EnumerationValue-1)<<1+((#PB_Compiler_EnumerationValue-2)&$8000000+(~-#PB_Compiler_EnumerationValue)&$8000000)>>27)
EndMacro
Enumeration #Null
#STPF_NONE =BinaryEnumeration
#STPF_USEAPPTHUMBNAILALWAYS =BinaryEnumeration
#STPF_USEAPPTHUMBNAILWHENACTIVE =BinaryEnumeration
#STPF_USEAPPPEEKALWAYS =BinaryEnumeration
#STPF_USEAPPPEEKWHENACTIVE =BinaryEnumeration
EndEnumeration
Debug #STPF_NONE
Debug #STPF_USEAPPPEEKWHENACTIVE
wilbert
PureBasic Expert
Posts: 3942 Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands
Post
by wilbert » Tue Jun 28, 2016 7:56 am
Code: Select all
EnumerationBinary
#STPF_NONE = 0
#STPF_USEAPPTHUMBNAILALWAYS = 1
#STPF_USEAPPTHUMBNAILWHENACTIVE
#STPF_USEAPPPEEKALWAYS
#STPF_USEAPPPEEKWHENACTIVE
EndEnumeration
Debug #STPF_USEAPPPEEKWHENACTIVE
Windows (x64)
Raspberry Pi OS (Arm64)
Michael Vogel
Addict
Posts: 2797 Joined: Thu Feb 09, 2006 11:27 pm
Contact:
Post
by Michael Vogel » Tue Jun 28, 2016 12:43 pm
wilbert wrote: Code: Select all
EnumerationBinary
#STPF_NONE = 0
#STPF_USEAPPTHUMBNAILALWAYS = 1
#STPF_USEAPPTHUMBNAILWHENACTIVE
#STPF_USEAPPPEEKALWAYS
#STPF_USEAPPPEEKWHENACTIVE
EndEnumeration
Debug #STPF_USEAPPPEEKWHENACTIVE
Nice try, Wilbert
I still prefer a fool proof handling, so the next value after 0 should be 1 - this could save you some time for trouble shooting.