Page 1 of 2

[Implemented] Step value to the power of X

Posted: Thu Sep 21, 2006 8:52 pm
by Hroudtwolf
Hello Fred and PureBasic team,

Its more an idea than a wish.
Could you please make it possible to use the power of x for the step keyword ?

Example:

Code: Select all

Enumeration 2 Step ^2
   #cDXSCREEN_RENDER_CLEARBYCOLOR
   #cDXSCREEN_RENDER_VSYNCOFF
   #cDXSCREEN_RENDER_VSYNCON
   #cDXSCREEN_RENDER_VSYNCIDLE
EndEnumeration
The set values...

#cDXSCREEN_RENDER_CLEARBYCOLOR = 2
#cDXSCREEN_RENDER_VSYNCOFF = 4
#cDXSCREEN_RENDER_VSYNCON = 8
#cDXSCREEN_RENDER_VSYNCIDLE = 16

Best regards.

Hroudtwolf

Posted: Thu Sep 21, 2006 9:01 pm
by hellhound66
Removed.

Posted: Thu Sep 21, 2006 9:04 pm
by Hroudtwolf
My idea is, to have the possibility to let increase the enumeration-value with the power of X.

Posted: Thu Sep 21, 2006 9:06 pm
by hellhound66
Removed.

Posted: Thu Sep 21, 2006 9:14 pm
by Hroudtwolf
Yes, thats also a good idea.

Posted: Sun Apr 15, 2007 12:19 am
by Bonne_den_kule
Good idea. PB should be enable to increase the enumeration value with the power of 2.

Posted: Sun Apr 15, 2007 6:25 am
by MrMat
Yeah i suggested this too:
MrMat wrote:Enumeration type for bitmasks, e.g.

Code: Select all

EnumerationBitmask 1
#MIIM_ID
#MIIM_SUBMENU
#MIIM_CHECKMARKS
#MIIM_TYPE
#MIIM_DATA
EndEnumerationBitmask
instead of

Code: Select all

#MIIM_ID = 1 << 1
#MIIM_SUBMENU = 1 << 2
#MIIM_CHECKMARKS = 1 << 3
#MIIM_TYPE = 1 << 4
#MIIM_DATA = 1 << 5
It would be really useful.

Posted: Fri Feb 15, 2008 4:27 pm
by #NULL
something like this would make much use for me too! and it would fit well into PB :)
+1

Posted: Tue Feb 19, 2008 5:06 pm
by NicTheQuick
+1

Posted: Tue Feb 19, 2008 5:13 pm
by hellhound66
Removed.

Posted: Sat Dec 06, 2008 10:50 pm
by #NULL
i found a way with macros, but it looks a bit silly :P

Code: Select all

Macro startFlags(set, starting_bit=1) 
  set = #PB_Compiler_Line + 2 - starting_bit 
EndMacro 

Macro nextFlag(set) 
  (1 << (#PB_Compiler_Line - set)) 
EndMacro 





startFlags(#myFlags) 
#a = nextFlag(#myFlags) 
#b = nextFlag(#myFlags) 
#c = nextFlag(#myFlags) 

Debug #a 
Debug #b 
Debug #c 

Debug "" 

startFlags(#Flags2, 3) 
#_1 = nextFlag(#Flags2) 
#_2 = nextFlag(#Flags2) 
#_3 = nextFlag(#Flags2) 
#_4 = nextFlag(#Flags2) 

Debug #_1 
Debug #_2 
Debug #_3 
Debug #_4 

Posted: Sun Dec 07, 2008 12:35 pm
by DoubleDutch
+1 very good idea

Posted: Sun Dec 07, 2008 1:33 pm
by Little John
#NULL wrote:i found a way with macros, but it looks a bit silly :P
Inspired by your idea, I found a simpler way.

//edit: even more simplified

Code: Select all

; successfully tested with PB 4.30 beta 5

Macro NextFlag (_factor_=2)
   ((#PB_Compiler_EnumerationValue-1)*_factor_)
EndMacro


;-- according to original example by Hroudtwolf:
Enumeration 2
   #cDXSCREEN_RENDER_CLEARBYCOLOR
   #cDXSCREEN_RENDER_VSYNCOFF = NextFlag()
   #cDXSCREEN_RENDER_VSYNCON = NextFlag()
   #cDXSCREEN_RENDER_VSYNCIDLE = NextFlag()
EndEnumeration

Debug #cDXSCREEN_RENDER_CLEARBYCOLOR
Debug #cDXSCREEN_RENDER_VSYNCOFF
Debug #cDXSCREEN_RENDER_VSYNCON
Debug #cDXSCREEN_RENDER_VSYNCIDLE
Regards, Little John

Posted: Sun Dec 07, 2008 1:45 pm
by PB
The more you post workarounds, the less likely it'll be done natively. ;)

Posted: Sun Dec 07, 2008 2:37 pm
by Michael Vogel
Another, even crazier (?) variant...

Code: Select all

Macro _skip_()
EndEnumeration
Enumeration (#PB_Compiler_EnumerationValue-1)<<1
EndMacro

Enumeration 1
	#a
	_skip_()
	#b
	_skip_()
	#c
	_skip_()
	#d
EndEnumeration

Debug #a
Debug #b
Debug #c
Debug #d
Michael

PS and, as a running gag - Purebasic could have some additional integrated integer functions like BitSet(), BitClr, BitTest()