You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • I think what you're after for docs is: https://www.espruino.com/Bangle.js+Stora­ge

    The \n shouldn't be needed in eval, but the first line:

    Puck.eval("load('timestamplog.app.js')"
    

    is probably causing you issues - eval tries to run the command and get the response, but in this case the command is effectively resetting the Bangle and loading your app. So load(..) returns undefined to your interface file, but now the Bangle is starting to load your app, during which time you call printHTMLStampLog.

    So I'd definitely put a 500ms delay after Puck.eval("load... with `setTimeout.

    But then what you're doing should work, but I'm concerned based on the name printHTMLStampLog that you're printing the information to the console, not returning it from the function?

    If so, Puck.eval is going to return what your function returns, not what it prints.

    You could potentially use Puck.write("\x10printHTMLStampLog(stampL­og)\n", output2=> ...) (which does need a \n after the command) which I think will write the command and then wait ~200ms or so for a response and return that (it may have a trailing > on the text you receive though).

    Personally, I probably wouldn't advise trying to push HTML from the Bangle up to the interface.html though- I'd just do Puck.eval(stampLog, ...) to get the stamplog into the webpage and then run printHTMLStampLog in the web browser.

    Ideally, you could even just do Util.readStorageJSON("timestamplog.json"­, ourput2=>...) in the web browser and could then avoid even having to load your timestamp app.

    Although it depends on how you wrote the data - if you're using a StorageFile you'll need Util.readStorageFile

About

Avatar for Gordon @Gordon started