Jump tables?

Blitz3D Forums/Blitz3D Programming/Jump tables?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

stevenm, that doesn't work that way. What case expect is an expression that will be compared to the one of the select (here it's 'foo') and execute the case whose expression evaluates to the same value (if there is one; if there is more than one then it's the first matching case that is executed).
So your example compiles because (foo > 5) and (foo > 8) are integer expressions that will evaluate to 0 or 1 depending on the value of foo. But doesn't do what you expect, as the first case will be executed if
(foo > 5) = foo, which happens only when foo = 0
The same goes for the second case, but it won't be executed as the first one has already been executed in that case.

Well, it's a lot of talking just for saying it doesn't work but I thought you could be interested.

Doing something like
Select True
Case foo > 5 ...
End Select
would work as long as your cases conditions are mutually exclusive (which is not the case here as foo can be say 7 and then we have foo > 5 AND foo > 8).
But that's a trick anyway, for such things you'd better use plains Ifs. Selects are really meant to be used like in C.
Note you can also have multiple values in a case:
"Case 5,6,7".

Strider Centaur: the compiler doesn't seem to compile Selects into jump tables, even for selects on integer expression.