Page 1 of 1

[Implemented] EnumerationBinary starting from 0

Posted: Tue Jun 28, 2016 7:51 am
by Michael Vogel

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

Re: EnumerationBinary starting from 0

Posted: Tue Jun 28, 2016 7:56 am
by wilbert

Code: Select all

EnumerationBinary
   #STPF_NONE = 0
   #STPF_USEAPPTHUMBNAILALWAYS = 1
   #STPF_USEAPPTHUMBNAILWHENACTIVE
   #STPF_USEAPPPEEKALWAYS
   #STPF_USEAPPPEEKWHENACTIVE
EndEnumeration

Debug #STPF_USEAPPPEEKWHENACTIVE

Re: EnumerationBinary starting from 0

Posted: Tue Jun 28, 2016 12:43 pm
by Michael Vogel
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 :P

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.