10 Common patterns

10.1 Hello world

HALT

Will render a template without any external symbols and terminate execution immediately.

10.2 Handling menus and inputs

MOUT to_foo 0
MOUT to_bar 1
MOUT upup 2
HALT
INCMP foo 0
INCMP bar 1
INCMP _ 2

Create three menu items, resolving the menu symbols to_foo, to_bar and upup respectively to translated text and pairing with the selectors.

Yield for client input. Then attempt to match input to selectors:

10.3 Signal flow control

LOAD foo 1
CATCH bar 8 1
MOVE baz

If loading the external symbol foo sets the flag 8, then immediately move to bar.

Otherwise, move to baz.

10.4 Multiple pages

LOAD foo 0
MNEXT to_fwd 11 
MPREV to_back 22
HALT
INCMP > 11
INCMP < 22

Load external symbol foo as a sink.

If content spans multiple pages, resolve to_fwd and to_back as labels for lateral navigation options in the menu.

Also handle the lateral navigation inputs.

10.5 Multi-page menus

MSINK
MNEXT to_fwd 11 
MPREV to_back 22
MOUT inky 0
MOUT pinky 1
MOUT blinky 2
MOUT clyde 3
MOUT tinkywinky 4
MOUT dipsy 5
MOUT lala 6
MOUT pu 7
HALT
INCMP foo 0
INCMP foo 1
INCMP foo 2
INCMP foo 3
INCMP foo 4
INCMP foo 5
INCMP foo 6
INCMP bar 7

Enable splitting menu over several pages, and route all valid inputs to the foo node, except for 7 which is routed to the bar node.

10.6 Default input handler

MOUT to_foo 0
HALT
INCMP foo 0
INCMP bar *

If input is 0, route to the foo. Any other input will route to the bar node.