Re: SWITCH question
- Posted by jimcbrown (admin) Jan 07, 2018
- 2113 views
I stand corrected by the facts about the switch-method because I assumed it was an intricate kind of error-handler, whereas it is in fact just a neater way to program nested if..elsif....else...endif constructions, and reacting to the result of that test.
Yeah, pretty much.
yielding TRUE or FALSE,
The values don't have to be true or false, as the equality test is internal.
This, however explains both its erratic behaviour and the fact that there are 2 different values returned. If I take the highest and call that TRUE (it might be the pointer to TRUE as well!) automagically the lower one will be (the maybe pointer to) FALSE.
Uh, no. That's not how it works.
But because it made you end up in the constant-table it is ofc a pointer.
There isn't a constant-table. (There is a list of symbol names used for error reporting, but that's not the cause of the problem.)
Having been too long `off scene` I assumed it still was Eu and not OE, that's why I pointed at RC and not at Derek as its creator.
OE was scooby's deal.
So the correct use of switch is: Switch (a) ....case (x) ....case (y) ....case (z) default endswitch
BUT NEVER Switch (a) .... case (a) or any condition containing (a) again because (a) has been checked by SWITCH already and will therefore inevitably send a TRUE, followed by the test-result of the next condition.
Actually, as long as a is a literal value or a constant/enum, the second case should be ok!