Select Case an Array

BlitzMax Forums/BlitzMax Beginners Area/Select Case an Array

Hezkore(Posted 2011) [#1]
Another quick question, how would I use an array with Select?

Local MyArray:string[5]

Select MyArray
Case
EndSelect

How would Case work? :o


Jesse(Posted 2011) [#2]
select is just a different way of doing an "if then elseif"

this :
if a = 1 then 
  ------
elseif a = 2 then
 -------
elseif a = 3 then
 --------
elseif a = 4 then
 --------
else
 --------
endif

is the same as this:
select a
     case 1
      ------
     case 2
     -------
    case 3
     -------
    case 4
     -------
   default
    --------
end select



so it depends what you want to do with the array that will determine how you construct the select/case.


Hezkore(Posted 2011) [#3]
But i want to compare the entire array in one case D:


Jesse(Posted 2011) [#4]
if you explain exactly what you want to do, there might be a way or an alternative route for you to take.


matibee(Posted 2011) [#5]
How about this...




Perturbatio(Posted 2011) [#6]

But i want to compare the entire array in one case D:


I guess you could do this:
Local myarray1:String[] = [ "a", "b", "c", "d" ]

Select True
	case myarray1[0] = "a" and myArray1[1] = "b"
		print "yes"
	default
		print "no"
End Select


But it's fugly.


Matty(Posted 2011) [#7]
Concatenate all your strings together and then check...a bit like a 'key field' in some databases.