This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
4rpl:commands:switch [2022/08/31 18:28] – created Karsten75 | 4rpl:commands:switch [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 6: | Line 6: | ||
:!: Available in version 2.4.4 and later. | :!: Available in version 2.4.4 and later. | ||
- | ====== | + | ====== |
switch | switch | ||
Line 12: | Line 12: | ||
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. | 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. | ||
+ | All code between '' | ||
+ | |||
+ | === Programming note === | ||
+ | The '' | ||
===== Examples ===== | ===== Examples ===== | ||
<code 4rpl> | <code 4rpl> | ||
switch | switch | ||
- | | + | case(< |
- | @HandleIdle | + | @HandleIdle |
- | endcase | + | |
- | | + | case(< |
- | @HandleMove | + | @HandleMove |
endcase | endcase | ||
- | | + | case(< |
- | @HandleFire | + | @HandleFire |
endcase | endcase | ||
+ | @HandleException # no case statement evaluated to TRUE | ||
endswitch | endswitch | ||
+ | </ | ||
+ | Second example | ||
+ | <code 4RPL> | ||
+ | true -> | ||
+ | Switch | ||
+ | Case (NOT (<-init) ) | ||
+ | Trace ("Case 1 is valid" | ||
+ | | ||
+ | False ->init | ||
+ | Case (<-init ) | ||
+ | Trace ("Case 2 is valid" | ||
+ | | ||
+ | | ||
+ | endSwitch | ||
+ | |||
</ | </ | ||