CompilerCase A,B,C

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

CompilerCase A,B,C

Post by Michael Vogel »

I'd like to have the possibility to use something like...

Code: Select all

Enumeration
	#X_A
	#X_B
	#X_C
	#X_D
EndEnumeration

#ScreenSaver=#X_A

CompilerSelect #ScreenSaver
CompilerCase #X_A,#X_B
	:
	:
	:
CompilerDefault
	:
CompilerEndSelect
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Post by helpy »

Workaround:

Code: Select all

Enumeration
   #X_A
   #X_B
   #X_C
   #X_D
EndEnumeration

#ScreenSaver=#X_A

CompilerSelect #ScreenSaver
	CompilerCase (#X_A | #X_B) & #ScreenSaver
	  Debug "#X_A,#X_B"
	  ;   :
	  ;   :
	  ;   :

	CompilerDefault
  	Debug "Default"
	  ;   :
	  ;   :
	  ;   :

CompilerEndSelect
cu, guido
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
Deeem2031
Enthusiast
Enthusiast
Posts: 216
Joined: Sat Sep 20, 2003 3:57 pm
Location: Germany
Contact:

Post by Deeem2031 »

This does not work:

Code: Select all

Enumeration 
   #X_A 
   #X_B 
   #X_C 
   #X_D 
EndEnumeration 

#ScreenSaver=#X_B

CompilerSelect #ScreenSaver 
   CompilerCase (#X_A | #X_D) & #ScreenSaver 
     Debug "#X_A,#X_D" 
     ;   : 
     ;   : 
     ;   : 

   CompilerDefault 
     Debug "Default" 
     ;   : 
     ;   : 
     ;   : 

CompilerEndSelect
If you want it to work this way the constants must use different bits:

Code: Select all

Enumeration 
   #X_A = 1<<0
   #X_B = 1<<1
   #X_C = 1<<2
   #X_D = 1<<3
EndEnumeration 

#ScreenSaver=#X_B

CompilerSelect #ScreenSaver 
   CompilerCase (#X_A | #X_D) & #ScreenSaver 
     Debug "#X_A,#X_D" 
     ;   : 
     ;   : 
     ;   : 

   CompilerDefault 
     Debug "Default" 
     ;   : 
     ;   : 
     ;   : 

CompilerEndSelect
Last edited by Deeem2031 on Thu May 07, 2009 4:57 pm, edited 1 time in total.
irc://irc.freenode.org/#purebasic
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Post by helpy »

Thank you Deem2031!!!

You are right!

At the beginning I had it in mind, but as I wrote/copied the code ... it got lost ;-) ... I took too less time ...
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
Post Reply