Append text line at the beginning of file?

 

Hi,

title says it all, normally when you use FileWrite method, string is appended to the end of file. However I would like the other way around if possible, that is to append the new strings at the beginning without overwriting existing content, so that the last string appended is always on top of file. Is this possible at all? Much thanks.

 
arcull:

Hi,

title says it all, normally when you use FileWrite method, string is appended to the end of file.

However I would like the other way around if possible, that is to append the new strings at the beginning without overwriting existing content, so that the last string appended is always on top of file. Is this possible at all? Much thanks.

Not possible. You have to read the existing content, append your new data and write all the file again.
 
Alain Verleyen:
Not possible. You have to read the existing content, append your new data and write all the file again.

Alain thanks, do you have any idea how would I read the file from end to the beginning? I have ASCII file with CRLF, something like this:


HOUR;MIN;BID;ASK

8;30;1,1223;1,1224

9;31;1,1226;1,1228

10;32;1,1221;1,1223


Or should I consider using MySQL instead, thanks.

 
arcull:

Alain thanks, do you have any idea how would I read the file from end to the beginning? I have ASCII file with CRLF, something like this:


HOUR;MIN;BID;ASK

8;30;1,1223;1,1224

9;31;1,1226;1,1228

10;32;1,1221;1,1223


Or should I consider using MySQL instead, thanks.

A loop with FileReadString().
 
Alain Verleyen:
A loop with FileReadString().
And check every loop if character is CR or LF, so that you know you are in new line?
 
But I should read char by char, FileReadString() can't read backwards, and I don't know in advance how much offset to make before new FileReadString.
Reason: