Most recent activity
-
- 13 comments
- 4,235 views
-
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 ! -
-
-
Good morning,
Look at this code, it draws 2 horizontal lines on the Bangle screen
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); }; var t= new Test(); t.draw(); g.drawLine(0,160,240,160);
When it is sent to the emulator, it works well.
When it is sent to the Bangle, it does not work properly, only the second line is drawn.
A dump to the console shows that the function draw() is not properly loadeddump()
function Test() {this.p1={x:0,y:80},this.p2={x:240,y:80};}
Test.prototype.draw = function (undefined) {return g.clear()};
var t = Object.create(Test["prototype"]);
t.p1 = { "x": 0, "y": 80 };
t.p2 = { "x": 240, "y": 80 };
E.setFlags({ "deepSleep": 0, "pretokenise": 1, "unsafeFlash": 0, "unsyncFiles": 0 });If I type this code in REPL mode with Bangle connected, it works well.
Where's the error ?
-
-
-
@Robin :
Thanks for the advice, I will no longer use this writing for prototypes. The problem still persists with the conventional form.
I'm not used to Github, but I'll try to do it.
@Gordon :
I'm a little ashamed. I didn't uncheck all options.
Obviously, it works on all devices. This reassures me, thank you.