Honestly I'm a bit stuck. I've tested here and it works fine.
All I have from you is 'it's not working' - and I can't even see a reference to any code you've got that is using .read?
If you did call .read with a bigger length than you have free RAM then yes, it'd likely fail with an out of memory error though...
Please could you see if you can produce a single JS file that you can upload that'll cause the problem? Maybe start from this and see what you have to do to get it to break.
f = require('Storage').open("foobar","w");
f.write("Hell");
f.write("o World\n");
f.write("Hello\n");
f.write("World 2\n");
var f = require('Storage').open('foobar', 'r');
var line = '';
while (line !== undefined) {
line = f.readLine();
print(line);
}
Just a note about your code - there's no need to do all those checks in the while loop. Just a single !==undefined will work just fine
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Honestly I'm a bit stuck. I've tested here and it works fine.
All I have from you is 'it's not working' - and I can't even see a reference to any code you've got that is using
.read
?If you did call
.read
with a bigger length than you have free RAM then yes, it'd likely fail with an out of memory error though...Please could you see if you can produce a single JS file that you can upload that'll cause the problem? Maybe start from this and see what you have to do to get it to break.
Just a note about your code - there's no need to do all those checks in the
while
loop. Just a single!==undefined
will work just fine