Download MetaTrader 5
To add comments, please log in or register
Track all payments in your profile. It is easy!
arcull
121
arcull 2015.10.01 20:59 

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.

Alain Verleyen
Moderator
30639
Alain Verleyen 2015.10.01 21:07  
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.
arcull
121
arcull 2015.10.01 21:33  
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.

Alain Verleyen
Moderator
30639
Alain Verleyen 2015.10.01 21:40  
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().
arcull
121
arcull 2015.10.01 21:47  
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?
arcull
121
arcull 2015.10.01 21:51  
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.
/
To add comments, please log in or register