LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continiously read a txt file

Hello fellows,
 
is there a way to read a *.txt file continiously without doing the simple while loop wich burns all the CPU ??
 
This txt file is generated by another application that pick up messages from a pipe and register messages in the txt file.
 
As a final goal the messages read in the txt file will control other executions in the vi.
 
Attached files: vi in LabVIEW 8.0 and the txt file.
0 Kudos
Message 1 of 7
(3,165 Views)
To stop the while loop from railing the CPU place a small 10ms delay in the loop.
Andrew Alford
Production Test Engineering Technologist
Sustainable Energy Technologies
www.sustainableenergy.com
Message 2 of 7
(3,160 Views)

Thanks, that's Ok now !

Another question, I want to do something (post a message as an example) each time the txt file is modified, how can I handle that ? with an event structure in the while loop?

 

Thanks for your support...Smiley Wink

0 Kudos
Message 3 of 7
(3,159 Views)
You can look at the modification date of the file. There's a "File/Directory Info" function. Use a shift register in the loop to keep track of the last date read, and compare it with the current date read. If it's different, the file's been modified.

Note: Your program may run into a conflict with the other program that's trying to write to the file. How big is this file? If your VI has the file open for reading, and the other program tries to write to it, the other program may get a file access error.
0 Kudos
Message 4 of 7
(3,147 Views)

Thanks for your solution, I will test that and keep you posted on my achievments...

 

0 Kudos
Message 5 of 7
(3,143 Views)


Novice programeur wrote:

Another question, I want to do something (post a message as an example) each time the txt file is modified, how can I handle that ? with an event structure in the while loop?



What type of message would you like to post...?  One within the actual txt file or one within LabVIEW that alerts you when the modification was made?
 
Regards
0 Kudos
Message 6 of 7
(3,133 Views)

Thanks for your interest ! !

The process will be as follows:

1-an application reads text in a serveur pipe and write it into the txt file.

2-The LabVIEW vi reads in loop the txt file and sort out the txt value each time that's updated by the application running in parralel.

The goal is to synchronize the labview execution with the new messages arriving in the txt file.

Thanks for your suggestions on how can I continiously read the txt file and take an action in the vi each time the txt file is updated with new text.

See you...

0 Kudos
Message 7 of 7
(3,127 Views)