[Implemented] Step value to the power of X

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

[Implemented] Step value to the power of X

Post 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
Last edited by Hroudtwolf on Thu Sep 21, 2006 9:02 pm, edited 1 time in total.
hellhound66
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Feb 21, 2006 12:37 pm

Post by hellhound66 »

Removed.
Last edited by hellhound66 on Wed Mar 19, 2008 11:36 pm, edited 1 time in total.
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

My idea is, to have the possibility to let increase the enumeration-value with the power of X.
hellhound66
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Feb 21, 2006 12:37 pm

Post by hellhound66 »

Removed.
Last edited by hellhound66 on Wed Mar 19, 2008 11:37 pm, edited 1 time in total.
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Yes, thats also a good idea.
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

Good idea. PB should be enable to increase the enumeration value with the power of 2.
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post 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.
Mat
#NULL
Addict
Addict
Posts: 1497
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Post by #NULL »

something like this would make much use for me too! and it would fit well into PB :)
+1
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Post by NicTheQuick »

+1
hellhound66
Enthusiast
Enthusiast
Posts: 119
Joined: Tue Feb 21, 2006 12:37 pm

Post by hellhound66 »

Removed.
#NULL
Addict
Addict
Posts: 1497
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Post 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 
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

+1 very good idea
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post 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
Last edited by Little John on Sun Dec 07, 2008 2:09 pm, edited 1 time in total.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

The more you post workarounds, the less likely it'll be done natively. ;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Post 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()
Post Reply