This looks really nice! Though I'll probably just stick with my many IF's and ELSEIF's.
I'm confused... What advantage does this have over comparison?
I mean, drop the SWITCH and ENDSW statements, and replace every CASE(K) with (TEST%==K) and you get the exact same thing. Am I missing something?
This does help a little bit with readability, but not by much.
The key issue with this library is it's required use of IFs, which the switch statements were intended to replace.
SWITCHes cannot be nested. You could fix this with VAR TOSWITCH$, in the SWITCH procedures use UNSHIFT, in the CASE functions, instead of TRIGGERED% use LEN(TOSWITCH$)>0, instead of TOSWITCH$ use TOSWITCH$, and in ENDSW use SHIFT.
It would be called SELECT CASE, since that's what it is in qbasic.
SELECT CASE variable
CASE value: do something
CASE othervalue: do something else
I use the ON command a lot, it works similarly and is good for my purpose.
Why was this removed? This would be very useful in my programs.