LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Don't understand file logger Write File basics

I have used the example in Basic I 8-5 to make a data logger. My vi works but I don't know why. I don't understand how the 'Write File' function accesses the disk. The file is actually written when the while loop ends. I will be running a logger for many hours and am worried that I may loose data if I have to abort a run. I will have 30,000-80,000 lines of data and wonder if I will choke the file system that LV uses.
0 Kudos
Message 1 of 2
(2,492 Views)
Hello �

From your question, I understand that you are working with Exercise 8-5 of the LabVIEW Basics I course manual.

In this exercise, a new line of data to be written to the file is created in every iteration of the while loop using the Build Text function. By �new line of data� I mean: the current date/time string, a Tab constant, the measured temperature and an End of Line constant. Once this new line of data is generated, it is sent to the file, through the Write File function, also in every while loop iteration. In other words, every time the while loop executes, a new line of data is written to the file.

The reason why the Open File and Close File functions are outside the loop (and not inside) is because it is more efficient to open the file once
, write all that needs to be written, and close it at the end of the execution of the program, rather than opening and closing it in every iteration.

If you need to abort the execution of the program, x number of lines of data will remain saved in the file, where x corresponds to the number of times the while loop executed. You won�t lose any already acquired data. You have to, however, make sure that the next time you run the program, you don�t replace the file (the example is set to create or replace) otherwise you will lose your data. For this, simply change the �create or replace� selection in the Open File function to �open or create�.

Hope this helps!

S Vences
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(2,492 Views)