Got an idea for enhancing PureBasic? New command(s) you'd like to see?
			
		
		
			- 
				
																			
								Kris_a							 
						- User

 			
		- Posts: 92
 		- Joined: Sun Feb 15, 2004 8:04 pm
 		
		
											- Location: Manchester, UK
 
							
						
		
		
						
						
													
							
						
									
						Post
					
								by Kris_a » 
			
			
			
			
			I had a quick search for something similar to this and found nothing, which was really suprising.
Code: Select all
Select Somevar
  case 1,2,3,4
    ; Do something
  case 5,6,7,8
    ; Do something else
endselect
This would be incredibly handy, at the moment I'm forced to use functions to execute the same code in two different 'select' situations.
Thanks 
-Kris
 
			
			
									
									
						 
		 
				
		
		 
	 
				
			
		
		
			- 
				
								blueznl							
 
						- PureBasic Expert

 			
		- Posts: 6172
 		- Joined: Sat May 17, 2003 11:31 am
 		
		
											
							- 
				Contact:
				
			
 
				
		
		
						
						
						
			
													
							
						
									
						Post
					
								by blueznl » 
			
			
			
			
			you're not the first one who wishes this...
			
			
									
									( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide 
right here... )
 
						 
		 
				
		
		 
	 
	
						
		
		
			- 
				
																			
								USCode							 
						- Addict

 			
		- Posts: 924
 		- Joined: Wed Mar 24, 2004 11:04 pm
 		
		
											- Location: Seattle
 
							
						
		
		
						
						
													
							
						
									
						Post
					
								by USCode » 
			
			
			
			
			I've seen some languages implement it this way:
Code: Select all
Select Somevar 
  case 1
  case 2
  case 3
  case 4
    ; Do something 
  case 5
  case 6
  case 7
  case 8 
    ; Do something else 
endselect 
Unfortunately, that doesn't work as desired in PB.  BUT that kind of syntax might be easier for Fred to implement.
 
			
			
									
									
						 
		 
				
		
		 
	 
	
						
		
		
			- 
				
																			
								GPI							 
						- PureBasic Expert

 			
		- Posts: 1394
 		- Joined: Fri Apr 25, 2003 6:41 pm
 		
		
						
						
		
		
						
						
													
							
						
									
						Post
					
								by GPI » 
			
			
			
			
			USCode wrote:I've seen some languages implement it this way:
Code: Select all
Select Somevar 
  case 1
  case 2
  case 3
  case 4
    ; Do something 
  case 5
  case 6
  case 7
  case 8 
    ; Do something else 
endselect 
 
Of all possibiltys the worst methode (and take much more writing-time).
When i remember right, C use something like this, but there you must exit a case with a "break" or it will run in the other case-statement...
 
			
			
									
									
						 
		 
				
		
		 
	 
	
						
		
		
			- 
				
								blueznl							
 
						- PureBasic Expert

 			
		- Posts: 6172
 		- Joined: Sat May 17, 2003 11:31 am
 		
		
											
							- 
				Contact:
				
			
 
				
		
		
						
						
						
			
													
							
						
									
						Post
					
								by blueznl » 
			
			
			
			
			i'd settle for the more or less common basic syntax:
case 1,2,3
case 3
default
etc.
			
			
									
									( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide 
right here... )
 
						 
		 
				
		
		 
	 
	
						
		
		
			- 
				
																			
								PB							 
						- PureBasic Expert

 			
		- Posts: 7581
 		- Joined: Fri Apr 25, 2003 5:24 pm
 		
		
						
						
		
		
						
						
													
							
						
									
						Post
					
								by PB » 
			
			
			
			
			> at the moment I'm forced to use functions
You could also just use 
If...ElseIf...EndIf like so:
Code: Select all
If Somevar>0 and Somevar<5 ; case 1,2,3,4
  ; Do something
ElseIf Somevar>4 and Somevar<9 ; case 5,6,7,8
  ; Do something else
EndIf
 
			
			
									
									
						 
		 
				
		
		 
	 
	
						
		
		
			- 
				
																			
								Alberto							 
						- User

 			
		- Posts: 25
 		- Joined: Mon May 19, 2003 4:59 pm
 		
		
						
						
		
		
						
						
													
							
						
									
						Post
					
								by Alberto » 
			
			
			
			
			I need lthis feature.
It's not indispensable but it's frustrating to fill the code with 
if...
if...
if...
if... 
 
A solution maybe the use of commas (is the best solution) or the use of a 'break' instruction like in the C language.
Ciao
Alberto
 
			
			
									
									
						 
		 
				
		
		 
	 
	
						
		
		
			- 
				
																			
								PB							 
						- PureBasic Expert

 			
		- Posts: 7581
 		- Joined: Fri Apr 25, 2003 5:24 pm
 		
		
						
						
		
		
						
						
													
							
						
									
						Post
					
								by PB » 
			
			
			
			
			> it's frustrating to fill the code with If, If, If, ...
It's no more frustrating than using multiple Case statements.
> or the use of a 'break' instruction like in the C language
PureBasic does have a Break command (see the docs).
			
			
									
									
						 
		 
				
		
		 
	 
	
						
		
		
			- 
				
																			
								Dare2							 
						- Moderator

 			
		- Posts: 3321
 		- Joined: Sat Dec 27, 2003 3:55 am
 		
		
											- Location: Great Southern Land
 
							
						
		
		
						
						
						
			
													
							
						
									
						Post
					
								by Dare2 » 
			
			
			
			
			But does not need breaks in Select/Case, and hopefully it stays like that.
However, 
case 1,2,5,9 TO 15,etc would be nice.
But first: Floats, fixed strings, thread safety, etc!  
