This is an old revision of the document!
⇐ Index
⇐ Flow Control
Available in version 2.4.4 and later.
switch
Allow for multiple selection control in a single, more compact form that multiple if/else if/endif endif format. This is intended to improve clarity by reducing otherwise repetitive coding.
The case
in a RPL language differs from case
in say, C. The logic before a case statement ultimately can do whatever it wants. In the end it should put something on the stack that the case evaluates as true or false. But there can be any amount of code that does anything before a case statement. This could lead to, for instance, the code in the second example that will not execute either of the two `case` statements.
switch case(<-currentState 0 ==) @HandleIdle endcase case(<-currentState 1 ==) @HandleMove endcase case(<-currentState 2 ==) @HandleFire endcase endswitch
Second example
true ->init Switch Case (NOT (<-init) ) Trace ("Case 1 is valid") endCase False ->init Case (<-init ) Trace ("Case 2 is valid") endCase endSwitch Trace("There is no case to be made")