This looks really nice! Though I'll probably just stick with my many IF's and ELSEIF's.
At first, when I looked at this library, I was like "pish that's what IF and ELSE does!". But then I started using JavaScript, and I was taught how to use SWITCH and CASE and I was like "WOW this will change everything! Anyways nice program. I like the way you did it.
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$[0], in the SWITCH procedures use UNSHIFT, in the CASE functions, instead of TRIGGERED% use LEN(TOSWITCH$)>0, instead of TOSWITCH$ use TOSWITCH$[0], 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
ENDSELECT
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.