05-13-2006, 06:50 AM
There is no way.
In old BASICs you could do something like:
this ain't possible in any version of MS BASIC as far as I know.
You have the ON choice GOTO label1, label2, label3..., but it translates roughly to the same code as a SELECT CASE. So it's better to use SELECT CASE just 'cause it's more readable and structured programming is the best solution 99% of the time.
The best solution to your problem would be what has been suggested. Profile your program and place the most likely cases first. Anyway, the assembly generated on a SELECT case is very optimized. You speak about 20 different cases on average. That would make, in the worst case, 20 simple expression evaluations and 20 short jumps. That's not a lot of time. If you are that concerned about optimization, just precalculate every expression in your CASEs.
There is a rule of thumb: finding a better algorithm is always better than optimizing a not so good one.
In old BASICs you could do something like:
Code:
GOTO 1000 + 100 * choice
this ain't possible in any version of MS BASIC as far as I know.
You have the ON choice GOTO label1, label2, label3..., but it translates roughly to the same code as a SELECT CASE. So it's better to use SELECT CASE just 'cause it's more readable and structured programming is the best solution 99% of the time.
The best solution to your problem would be what has been suggested. Profile your program and place the most likely cases first. Anyway, the assembly generated on a SELECT case is very optimized. You speak about 20 different cases on average. That would make, in the worst case, 20 simple expression evaluations and 20 short jumps. That's not a lot of time. If you are that concerned about optimization, just precalculate every expression in your CASEs.
There is a rule of thumb: finding a better algorithm is always better than optimizing a not so good one.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i