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: 

How to delete all data in a file

Hello.
 
I am trying to clear all the data from a file that will be continually replaced with a file of the same name with new data in it.  The goal is to delete the file while going through a while loop.  The problem I am having is with a dialog box popping up asking me if I want to replace the existing data.  I don't want a dialog box to pop up, just for the loop to continuosly delete any information (or to write a null string into the file) while it is looping, even if the file is empty.  At some point, the file will be replaced by actually data, which will cause a case structure to react and trigger the program to begin.
 
Attached is the file.
 
Thanks for the help!
 
Tyler
0 Kudos
Message 1 of 4
(2,562 Views)
Hello Tyler,

why don't you use the 'Delete' functions inside the file palette?
Some structure like this should be useful:
IF file_is_available THEN delete(file)
IF error THEN warn(user)

Check the error cluster after the delete function, maybe the user has no sufficient privileges the delete the file...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(2,545 Views)
Hello Tyler,

now I had a look into your vi and made some comments on it.
If your vi contains only LV functions you don't need to save as llb with all subVI from lv.lib!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 4
(2,539 Views)
Hello Tyler,

If you open up your "Write Characters to File.vi" sub vi you will see a sub vi called "Open/Create/Replace File.vi". This vi has as one of it inputs "Advisory Dialog". Currently nothing is wired into this input and the default value for this input is true and is why you keep getting a warning that you are about to overwrite an existing file. You need to wire up a boolean constant (false) into this input and the advisory should stop. You should then rename the sub vi to something like "My Write Characters to File.vi".

hope this helps

--Russ
0 Kudos
Message 4 of 4
(2,538 Views)