I have done some experimenting with numbers read from a file and found the following two problems:
require("Storage").write("test","teststring");
require("Storage").read("test");
let newString = require("Storage").read("test");
newString += "other";
// "other" is missing from string
print(newString);
require("Storage").write("test","123");
require("Storage").read("test");
let newString = require("Storage").read("test");
newString += 123;
// internal error, same if appending string to number read from file
print(newString);
I imagine both of these are caused by the file based strings mapped directly to the file instead of living in RAM as the other strings do.
This behaviour can be worked around by prepending an empty string when reading:
newString = "" + require("Storage").read("test");
Does this mean, that the whole resulting string is in RAM? Not that bad for my usecase, since I am reading a few bytes at a time from a bigger file, but could be relevant when reading whole files.
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.
I have done some experimenting with numbers read from a file and found the following two problems:
I imagine both of these are caused by the file based strings mapped directly to the file instead of living in RAM as the other strings do.
This behaviour can be worked around by prepending an empty string when reading:
Does this mean, that the whole resulting string is in RAM? Not that bad for my usecase, since I am reading a few bytes at a time from a bigger file, but could be relevant when reading whole files.