Select Case w/And

Blitz3D Forums/Blitz3D Beginners Area/Select Case w/And

Gauge(Posted 2004) [#1]
How can i Use and in a select case statement? this won't work:

Select True
n=len(command$)
Case command$=Left$("title",x) and n>2
;do case stuff


soja(Posted 2004) [#2]
There's nothing syntactically wrong with what you have, except the "n=..." line needs to be above the Select statement (and you need an End Select, of course).

This works fine:
command$="title"
n=Len(command$)

Select True
	Case command$=Left$("title",5) And n>2
		Notify "hi"
	Default 
		Notify "nothing"
End Select



Gauge(Posted 2004) [#3]
that was a typo accidently, but hrrm it won't work for me, oh well.


Klaas(Posted 2004) [#4]
Select works somewhat different .. you can not use it in that way
try this !
command$="title"
Select Left$(command$,5)
Case "title"
	Notify "hi"
Default 
	Notify "nothing"
End Select



puki(Posted 2004) [#5]
You can use 'And' - not sure how you want to use it, however:

command$="title of a book"
n=Len(command$) 
x=5
n=3; change to 1 to force the second check to be carried out

Select True 
Case Left$(command$,x)="title" And n>2 
	Print "You can do this if n is greater than 2"
	
Case Left$(command$,x)="title" And n<2
	Print "You can do this too if n is smaller than 2"
End Select



soja(Posted 2004) [#6]
Klaas, it's perfectly fine to Select on True -- as long as you make sure your Cases are mutually exclusive (if you want it to work well, that is).

Gauge, the Select and And work fine -- if it's not working, it's your logic. I have no idea what x is, and why you're using Left$ on a constant string ("title"), but the way you have it, it will only be True in these cases:
command$ = "tit" and x = 3
command$ = "titl" and x = 4
command$ = "title" and x = 5