From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I'm trying to write a VI that updates a file each time it is run, but on a new day a new file is created which is updated until a new day begins.

Solved!
Go to solution

I have written a VI to create and update a file as many times as needed on any given day. On any subsequent day a new file is created which for that day will be updated each time the VI is run and so on. The problem is that when I run the VI the first time of a new day, ie when the file is created only data is written to the file and not the header data. When the file is appended, header data, and regular data is properly written to the file. Can anyone tell me how to correct this problem? A copy of the VI that I wrote is attached.

 

Thanks,

Chuck M.

0 Kudos
Message 1 of 3
(2,453 Views)
Solution
Accepted by topic author chuck72352

You had the header information written when there wasn't an existing file, then you overwrote that file with another file consisting only of the data because you wired the "append to file? (new file:F)" the same for both functions (F causes it to create a new file).  I put the header writing function in a Case structure because you only want it to execute when this is a new file (otherwise it'll overwrite what's there).  Wire the path straight through the False case.  I wired a TRUE to the data writing function to always append (because there will always be a file by the time the program gets there).

Jim

 

PS - a few other observations

  • Avoid sequence structures
  • You don't need the property node
  • Use Path functions (not string)
Message Edited by jcarmody on 04-13-2009 05:58 PM
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 2 of 3
(2,435 Views)

Thanks for your help. Your solutions works perfectly. I want a header printed each time I run the VI so I added the "Write File" function to the "T" condtion of the case statement with true wired to it from the case selector in addition to what you have shown.

 

 

0 Kudos
Message 3 of 3
(2,409 Views)