Quick question about case select

BlitzMax Forums/BlitzMax Programming/Quick question about case select

Rimmsy(Posted 2006) [#1]
Is it possible to do select like this?
Select Rand(1,50)
	Case 1..25
		Print "1..25"
	Case 26..29
		Print "26..29"
	Case 30..50
		Print "30..50"	
End Select

I thought ".." might do it but doesn't seem to. Any help?


Beaker(Posted 2006) [#2]
Local a% = Rand(1,50)
Select True
	Case InRange(a,1,25)
		Print "1..25"
	Case InRange(a,26,29)
		Print "26..29"
	Case InRange(a,30,50)
		Print "30..50"	
End Select

Function InRange(num%,lo%,hi%)
	If num >= lo And num <= hi Return True
	Return False
End Function



Hummelpups(Posted 2006) [#3]
You solved te problem nicely. good work.


Rimmsy(Posted 2006) [#4]
Yeah. Good call.

Thanks beaker.


Diablo(Posted 2006) [#5]
different way (no function)
SeedRnd(MilliSecs() )
Local num% = Rand(0 , 50)
Select True

	Case num => 30 And num <= 50
		Print "30..50"
	Case num => 26 And num <= 29
		Print "26..29"
	Case num => 1 And num <= 25
		Print "1..25"
	Default
		Print "number not in range {" + num + "}"
		
End Select