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: 

file overwrite checking

Solved!
Go to solution

I wish to save data from a data acq process to a file.  First I want to check if specified file exists, and if so, ask user whether or not to overwrite, and if not overwrite, get a new file spec.  Attached code fragment is supposed to do all this, but doesn't completely work.  The basic idea is to wait in  the little while loop on right hand side of block diagram until a "stop waiting" signal is received.  The VI works correctly if file doesn't exist.  If file does exist, VI correctly asks user whether or not to overwrite, and it correctly continues if user says "Overwrite".  But if user specifies an alternative file, even one that doesn't exist, the program doesn't continue as it should.  Instead, it keeps asking user for a new file name, because it fails to recognize that a new name has been specified.  How to fix?  Is there an easier way to do this?  Thank you.

0 Kudos
Message 1 of 5
(3,111 Views)

Hi,

 

Try change the boolean constant of the false situation of the innermost case structure to true. Is that what you want?

 

I don't understand why you need the small while loop though.

Message 2 of 5
(3,102 Views)
Solution
Accepted by topic author WCR

Like I said in the other message thread, the right hand while loop doesn't do anything.  It will either run once, or run forever.  So eliminate.

 

In the rest of the code move the while loop outside of the case structure.  Use a shift register to pass the new filename back into the next loop iteration to check again if it exists.

0 Kudos
Message 3 of 5
(3,100 Views)

Thank you.  I tried your suggestion.  When I do, the VI accepts whatever the user enters, even if it is the same already-existing file name as before, or a name of a different pre-existing file.  In such a case, user should be asked again if he/she wants to overwrite the file, or specify an alternative file name.

 

The little while loop at right serves a purpose in the larger VI of which this is a fragment.  It makes the VI wait until there's a "good" filespec.  I could have used a sequence structure, but this solution makes for a neater block diagram in my opinion.

0 Kudos
Message 4 of 5
(3,094 Views)

Thank you again Ravens Fan.  Your solution is exactly what I need.

My earlier reply was to bo200008 whose response I also appreciate.

 

0 Kudos
Message 5 of 5
(3,090 Views)