Select Case...?

BlitzMax Forums/BlitzMax Beginners Area/Select Case...?

Amon(Posted 2007) [#1]
Why Can't I do this?

Select MapArray[x,y].frame
case 1 to 10
dostuff!
===========

Do I have to code it the long way by providing a case for each frame.

ie.

case 1
dostuff

case 2
do stuff

????

[edit] Yeah, I had to do it the long way. :)


Gabriel(Posted 2007) [#2]
You can separate cases with commas if you prefer

Select MapArray[x,y].frame
   Case 1,2,3,4,5,6,7,8,9,10
   Case 11,12,13,14,15,16,17,18,19,20
   ' ETC..
End Select


It's not as readable, IMO, but I think it works.

I think this would also work?

Select True
   Case MapArray[X,Y].Frame>=1 And MapArray[X,Y].Frame<=10
   Case MapArray[X,Y].Frame>=11 And MapArray[X,Y].Frame<=20
   ' ETC..
End Select



Amon(Posted 2007) [#3]
Hi. I tried the second method but it borks up collision for some reason. Can't quite figure out why.

I'll try your first method now.

Thanks for your help. :)

edit: The first method works perfect. Thanks :)


Czar Flavius(Posted 2007) [#4]
Try using an If-Else chain, which I believe the select-case gets turned into anyway?