04-14-2011 04:27 AM
Agnya
Sorry, from your pseudocode I thought that you were writing the file elsewhere in your code. The code from Robert demonstrates that a chenge in the file can be detected and read when the other application closes it, which presumably flushes it disk.
Most operating systems will buffer file writes in memory, and only peridodicly write to disk, typically when the buffer is full, when the file is closed, or if the application requests an explicit flush to disk. Windows _should_ allow your application to read any data still in the file buffer transparently, so you do not need to know whether the data you are requesting is in the buffer or on disk. I do not know whether it does.
More importantly, what is the behaviour of your other application, the one that is writing data to the file for you? If there is any intermediate buffering, then the behaviour might not be what you expect. I suggest you use Robert's code and check that new data is appearing in the file when you think the other application should have sent it.
04-14-2011 09:37 AM
Thank you, the most important thing for me is the continuous reading from a file...
04-14-2011 12:13 PM
Hi Roberto,
I am stack again trying to put it the way I want it. Could run the attached files and help me correct it? It is reading file "Writefile1" and output it at cell (2,1).
thank for your help
04-14-2011 01:59 PM - edited 04-14-2011 02:00 PM
I agyna,
I have corrected some mistakes in your project.
Basically you were stuck in the reading loop in OkCallback since you excluded end-of-file test. Please note that this test is to be executed immediately aftere reading, since in case of end-of-file the returned string is empty so if you put it in the table it clears the existing string.
A similar error was present in the timer callback, where the wile loop was never ending for the same reason. Additionally you weren't testing file size so the loop was never executed!
Last hint. When you want to post a project please be sure not to post neither cvibuild.xxx directory nor the temporary executable (in this case *_dbg.* files): adding these elements unnecessarily increases attachment size as those files are automatically created by the IDE (existing ones are rewritten)
04-14-2011 02:22 PM
Thanks a lot, It works fine.