E.showMenu problems with few items

Posted on
  • I'm trying to program the settings for an app. All bigger numerical values show up and are selectable without any problems. However the last setting can be selected between Always/Alarms/Never. It shows up nicely in the menu but when I try to select an Item I get a horribly garbled error message in the console and nothig is saved to JSON. However the value in the variable is correctly set. The "Weekend Start Hour" menu works as it is supposed to however the "Follow DND" gives the error.

    If I remove writeSettings() from line 31 the menu works as expected but of course it then doesn't save anything when switching apps.

    This is the code in question:

     ( function(back) {
      var FILE = "annoy.json";
      var dndChoices = ["Always", "Alarm", "Never"];
      var settings = Object.assign({
        // Default values
        wes: 13,
        dnd: 0},
        require("Storage").readJSON(FILE, true) || {});
      function WriteSettings(){
        require("Storage").writeJSON(FILE, settings);
        "" : {"title" : "Annoy"},
        "Weekend Start Hour": {
          value: 7|settings.wes,
          min: 0, max: 23,
          onchange: v => {
            settings.wes = v;
          format: v => v+"h",
        "Follow DND": {
          value: 0|settings.dnd,
          min: 0, max: 2,
          format: v => dndChoices[v],
          onchange: v => {
            settings.dnd = v;
            console.log(v, settings.dnd);

    And the error:

    |___|                 _
             |_| espruino.com
    1 1
    Uncaught ReferenceError: "writeSings();
                           a.value);r.scroll=l.scroller.scry<a.y-4|­|(b=k(c.y),(0>f||0<=b)&&d from line 1 col 17
  • Addendum, the problem also appears with the first menu item, I just didn't test it properly, my bad.

  • ... aaand it was PEBCAK all along. I misspelled writeSettings (capital W). I retried it in the Web IDE (I was using the local windows version as it allows for Projects) and it finally showed a proper error message. I'll show myself out.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

E.showMenu problems with few items

Posted by Avatar for Jonathan @Jonathan