Edit a specific line in a file.

 

I have a file with 1000 line such as : 

1;2;1;3

2;5;8;6

6;3;1;2

1;8;2;8

2;4;1;4

2;7;2;3

I wnat to search for a row that : the first column is 6 and second column is 3 (Here is the third row ) and then I must add a  number 8 to end of the file :

6;3;1;2;8

How can I do this and go the pointer to end of third line?

 
mir202020: I have a file with 1000 line such as : I wnat to search for a row that : the first column is 6 and second column is 3 (Here is the third row ) and then I must add a  number 8 to end of the file : 6;3;1;2;8 How can I do this and go the pointer to end of third line?

You can't insert data into the middle of a standard text file or sequential data file and shift the rest. You would need to rewrite all the remaining data from that point onwards. This is valid for any system, not just MQL.

One solution is to use a different file structure. Another is to use a database.

EDIT: Another option is to read the entire file in, make the changes and write it all out again.

 
Fernando Carreiro:

You can't insert data into the middle of a standard text file or sequential data file and shift the rest. You would need to rewrite all the remaining data from that point onwards. This is valid for any system, not just MQL.

One solution is to use a different file structure. Another is to use a database.

EDIT: Another option is to read the entire file in, make the changes and write it all out again.

Thank you very much.

Reason: