• Now test with this code :

    function Test() {
      this.p1 = {x:0, y:80};
      this.p2 = {x:240, y:80};
    }
    
    Test.prototype.draw = _=> {
      g.clear();
      g.drawLine(0,80,240,80);
      return true;
    };
    
    var t= new Test();
    if (t.draw()) {
      g.drawLine(0,160,240,160);
    }
    
    

    It works in the emulator but not on Bangle, only the first line is drawn and an error message appear on console ( see screen copy )

    I have tested on Pico with this similar code :

    function Test() {
      this.p1 = {x:0, y:80};
      this.p2 = {x:240, y:80};
    }
    
    Test.prototype.draw = _=> {
    //  g.clear();
    //  g.drawLine(0,80,240,80);
      console.log('line1');
      return true;
    };
    
    var t= new Test();
    if (t.draw()) {
    //  g.drawLine(0,160,240,160);
      console.log('line2');
    }
    

    same problem , with this message error :


    | |_ ___ ___ _ ||___ ___
    | |_ -| . | _| | | | | . |
    |
    |_| || |_|||_|_|

         |_| espruino.com
    

    2v04 (c) 2019 G.Williams
    line1
    Uncaught SyntaxError: BREAK statement outside of SWITCH, FOR or WHILE loop
    at line 4 col 22
    console.log('line1');return true;
    ^
    in function "draw" called from line 7 col 10
    if(t.draw()){console.log('line2');

    (test are made without minification)
    Strange !

About

Avatar for Robin @Robin started