• As @fanoush says you can move the console elsewhere. Maybe try something like:

    function ask(text, callback) {
      Bluetooth.println(text);
      Bluetooth.on('data',function(d) {
        Bluetooth.removeAllListeners("data");
        callback(d);
      });
    }
    
    function go() {
      // Move console out the way
      LoopbackA.setConsole();
      ask("A, B or C?", function(d) {
        Bluetooth.println("You picked "+JSON.stringify(d));
        ask("1, 2 or 3?", function(d) {
          Bluetooth.println("You picked "+JSON.stringify(d));
          /* Move the console back so you
          can interact with the REPL again. If you don't
          you'll have to disconnect and reconnect via
          Bluetooth to get it back */
          Bluetooth.setConsole();
        });
      });
    }
    

    Note that while the console is out the way, print/etc won't work either and you can't interact with the REPL.

    As @allObjects says, having A() etc is super easy to do though.

    Another option based on that is to use 'getters' that got introduced in new Espruino 2v00ish, which will work in a similar way, but without you needing the brackets:

    >Object.defineProperty(global,"a",{get:()=>print("you picked 'a'")})
    ={...}
    >a
    you picked 'a'
    
About

Avatar for Gordon @Gordon started