Writing to the file on a new line - page 2

 
EfremovSergey:
How can you delete a string after reading it, is there any simple way to do it?

Read by whom? If by you, you can erase it with your hands. If by a robot, it is pointless. You can make a decision on the algorithm as soon as you receive the data.

 
Valeriy Yastremskiy:

Read by whom? If by you, you can erase it with your hands. If by a robot, it is pointless. You can make a decision on the algorithm as soon as you receive the data.

In my view, if you don't get rid of the already processed information, then you have to spend resources on re-analysing it.

 
Ihor Herasko:

In most cases, it is better to read the entire file, make the necessary changes in memory with the data, and then overwrite the entire file. This is easier than moving the data within an open file.

If one EA is reading a file in its entirety, can another EA access the same file at the same time as the first one to make its own actions?

For experiment, I opened the file manually and tried to write the Expert Advisor to it; the information was displayed only after reopening.

If I try to open the file manually, while the Expert Advisor is working on the file, it simply refuses to open it, because the file is too busy with the process.

I do not fully understand the regulation. It will not work out that in the case of total overwrite, all that has not yet been read will be deleted?

Another detail is that the file is accessed by different Expert Advisors and they do not know whether other Expert Advisors have already read the information relevant to them or not, so that the entire file can be purged.

 
EfremovSergey:

If one EA is reading a file in its entirety, can another EA access the same file at the same time as the first one to make its own actions?

For experiment, I opened the file manually and tried to write the Expert Advisor to it; the information was displayed only after reopening.

If I try to open the file manually, while the Expert Advisor is working on the file, it simply refuses to open it, because the file is too busy with the process.

I do not fully understand the regulation. It will not happen that in the case of total overwrite, all that has not yet been read will also be deleted?

When opening file, add co-read flag FILE_SHARE_READ, maybe you will need co-edit flag {write} as well. It's up to you to decide if this is necessary.

 
Alexey Viktorov:

When opening a file, add FILE_SHARE_READ co-read flag, possibly also co-edit/ write flag. It 's up to you to decide if it's needed.

Ok. Thank you very much. Useful information.

And how to delete just one line, can anyone suggest?

 
EfremovSergey:

Okay. Thank you very much. Useful information.

Can anyone suggest how to delete just one line?

It depends on which line. I haven't done it, but if I have to, I'll start by experimenting on my own. Who wants to experiment with other people's ideas? Except from idleness. See if it's possible to read your file into SQLite database, delete this string and write it back. If it can be written to an array or an array of structures, you can do it too. But the problem is that arrays and structures are written in .bin files, which nothing else will not open and look at. In general, flight of fancy and experimentation in trying to achieve a result.

 
Alexey Viktorov:

It depends on what kind of string. I haven't done it, but if I have to, I'll start by experimenting on my own. Who wants to experiment with other people's ideas? Except from idleness. See if it's possible to read your file into SQLite database, delete this string and write it back. If it can be written to an array or an array of structures, you can do it too. But the problem is that arrays and structures are written in .bin files, which nothing else will not open and look at. All in all, it's a flight of fancy and experiments in trying to get a result.

An ordinary text file... If you don't know how to do it, the question disappears by itself, everyone experiments with it. The concept lies on the surface, as they say, and does not require any additional voiceover.

 
EfremovSergey:

Can anyone suggest how to delete just one line?

The easiest way is to read the file, process the data, write it back. Editing file data directly without asking too many questions is only possible character by character: read a character and write it back in place of the information to be deleted. Overwriting in blocks is more difficult as different pieces of data can overlap. Thus, all this is complicated and it's not quite clear why it is needed. Is there really not so much RAM? But then the operation of a large number of programs will not be possible either.

 
EfremovSergey:

A plain text file... If you don't know how to do it, then the question disappears on its own, everyone experiments as best they can, whatever they know how to do. The concept lies on the surface, as they say, and does not require any additional voiceover.

Well, if you think that the information "Normal text file ..." is enough, then you just to telepaths. I don't know the address, you can find it yourself. For some reason you don't take into account that even text files are different. Is there a line terminator, what's in the file: numbers or text, and there may be other nuances.

Igor offered you the easiest way. You probably did not like it, so I suggested you to experiment. And the concept is only for you on the surface.........

 
Ihor Herasko:

The easiest way is to read the file, process the data and write it back. Editing the file data directly without asking too many questions is only possible character by character: read a character and write it in place of the information to be deleted. Overwriting in blocks is more difficult as different pieces of data can overlap. Thus, all this is complicated and it's not quite clear why it is needed. Is there really not so much main memory? But then the operation of a large number of programs would not be possible either.

Here's the catch: there are 10 programs that write to the file and another 10 that read from it, you don't want each reading program to process the entire accumulated data array for all time.

Files:
Copy.txt  1 kb