LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

read from file continuoulsy

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.

0 Kudos
Message 11 of 15
(971 Views)

Thank you, the most important thing for me is the continuous reading from a file...

0 Kudos
Message 12 of 15
(966 Views)

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

0 Kudos
Message 13 of 15
(957 Views)

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)



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 14 of 15
(947 Views)

Thanks a lot, It works fine.

0 Kudos
Message 15 of 15
(944 Views)