• Not a perfect solution, but until you have something more elaborate: make the menu point A, B and C... and ask to enter A, B or C appended with (), for example: B(). This is like ad-hoc invoking the function B() on the Espruino board. Before showing the menu, define the A(), B() and C() ... functions (body) and delete them after menu input... (Instead of define and delete, assign A, B and C to and existing empty function, before the menu you assign them the desired existing functions, and afterwards you re-assign them again to the empty function.) That's the least intrusive option.

    The other option is to loop something into the console loop: before it reaches the JavaScript interpreter, you catch it, test it, and do what you need, and if it is not the menu thing, you pass it untouched... (Loopback?) may be you can put something into the echo-routined (post vs pre, and then clean out the expression input buffer of the JavaScript interpreter)... About the details: I'm not knowledgeable enough, would need to do some research.

    You can make the both flag/state controlled, so you do not have to setup and tear down for every menu.


Avatar for allObjects @allObjects started