There's nothing built-in, but I did do something for the laser cutter that worked quite well. I just stripped it down for you below:
function readLines(fileName, lineCallback, completeCallback) {
var f = E.openFile(fileName);
var buffer = f.read(64);
if (buffer===undefined) {
console.log("Couldn't load file");
completeCallback();
return;
}
function newLine() {
// get new data from file
while (buffer.indexOf("\n")<0) {
var r = f.read(64);
if (r===undefined) {
f.close();
break;
}
buffer += r;
}
// if we didn't get any data, finish...
if (buffer==="") return completeCallback();
// get new line
var eol = buffer.indexOf("\n");
if (eol<0) eol = buffer.length;
var line = buffer.substr(0,eol);
buffer = buffer.substr(eol+1);
lineCallback(line);
setTimeout(newLine, 1); // next line on idle
}
newLine();
}
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.
There's nothing built-in, but I did do something for the laser cutter that worked quite well. I just stripped it down for you below: