You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • You can't really edit a value in the file without re-saving it. Flash memory starts at 1 and can only be made zero, so all you could do with just Storage is to zero out an area, which would probably make life hard later on.

    I think your best bet is to use StorageFile, but if you want to delete a line you just iterate, writing just the stuff you want into a new file:

    // delete last line
    var src = require("Storage").open(STORAGE_FILE_A, "r");
    var dst = require("Storage").open(STORAGE_FILE_B, "w");
    var line = src.readLine();
    var newLine = src.readLine();
    while (line && newLine) { 
      dst.write(line+"\n");
      line = newLine;
      newLine = src.readLine();
    }
    

    Since you're loading line by line memory won't be an issue, and for 50k max it shouldn't take too long - it just means you have to have your file name changing (since you can't rename).

    Or depending how you're working with this, you can just add a line saying DELETE LAST LINE
    and then when you finally read the log out you use that to ignore the previous line if you see it?

About

Avatar for Gordon @Gordon started