LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How is a VI written to generate a new file only if the date changes.

Does anyone have a VI or know how to write one that stores info to a text file, creating a new file automatically only when the day changes. That is, regardless of the number of times the VI is run in a day I want to store all the results into a single file by appending it. If the date changes I want to have a new file automatically created and have all the data for that particular day stored in the new file.

 

Thanks.

0 Kudos
Message 1 of 4
(2,694 Views)
You asked the same question way back in March. Did you try jmcbee's suggestion?
0 Kudos
Message 2 of 4
(2,682 Views)

I would like to keep files and create a new file at the beginning of a new day. The problem is that I dont know how to find the latest file to open in order to read the date stamp that I have in the file prior to storing data. Ideally I would like to create a new file with the same name except for a date appended to the end of the file name each time that I run the program. Is this possible?

 

Thank you,

Chuck M.

0 Kudos
Message 3 of 4
(2,651 Views)

Well, you sort of answered your own question.  If you use a filename that includes the date, then it doesn't matter what the last file you used was.  If you are not saving that much data at a high rate, then just open the file, add the data, and close the file everytime.  You won't want to use the simple VIs as they ask you to replace, but the lower level file VIs can allow to select "open or create".  That way, if the file does not exist (new date), LabVIEW will create it.  If the file does exist (same day), LabVIEW opens it and you append data to the end of the file.

 

If you are doing a lot of file saving, you may want to open the file once and save data, leaving the file open.  If that is the case, then you need to store the date (or the filename) when you open/create the new file (using a shift register or feedback node).  Everytime you write data to the file, check the current date (or filename) with the date (or filename) saved.  If they are the same, then you just write data to the currently opened file.  If they are different, then you close the current open file, create the new file, and write the data, passing the new file reference out.

0 Kudos
Message 4 of 4
(2,640 Views)