SOLVED: Add/Remove from Beginning of File.
Posted: Thu Aug 22, 2013 8:21 pm
Just as the title states. I need a way of adding data to or removing data from the beginning of a file. The only available options for writing files in LiveCode are to overwrite the entire file, overwrite existing characters, or add to the end. These won't work for what I need.
I managed a set of shell commands that can put text at the front of the file, but it is near impossible to remove text from the front of files using shell commands and it is very slow even with what I have working so far.
I would just read in the file, add/remove what is needed, and overwrite the existing file with the new content, but LiveCode does not read NULL characters when using the "read from file" command. They are converted into ASCII 32 characters when put into the "it" variable even though notepad++ displays them as [NUL] even when using "write NULL to file..." and chartonum(NULL) returns 0, definitely not 32. I have found no documentation showing how to read NULL characters and other non-printing characters, such as EOF, from file correctly. Even doing a "read from file.. until EOF", then "write it to file..." gives you a file with exactly the same number of characters, but it is corrupted beyond repair.
Of course, it would be best to not read in the entire file since that would put constraints on file size based on available memory... but I'll take whatever I can get.
I managed a set of shell commands that can put text at the front of the file, but it is near impossible to remove text from the front of files using shell commands and it is very slow even with what I have working so far.
I would just read in the file, add/remove what is needed, and overwrite the existing file with the new content, but LiveCode does not read NULL characters when using the "read from file" command. They are converted into ASCII 32 characters when put into the "it" variable even though notepad++ displays them as [NUL] even when using "write NULL to file..." and chartonum(NULL) returns 0, definitely not 32. I have found no documentation showing how to read NULL characters and other non-printing characters, such as EOF, from file correctly. Even doing a "read from file.. until EOF", then "write it to file..." gives you a file with exactly the same number of characters, but it is corrupted beyond repair.
Of course, it would be best to not read in the entire file since that would put constraints on file size based on available memory... but I'll take whatever I can get.