LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced File Functions

Hello all,
 
I have a subVI that deletes 5 files which should always be present on my desktop due to a run before.  However, I have to put in a fail-safe that skips the delete process if the files are for some reason missing.
 
Attached is the simple file path constant and Delete file directory process that I currently use.
 
Is there any way I can utilize any of the other Advanced File Functions with a Case Structure and other Boolean Functions that can detect whether or not the files are there and then delete them if they are, or just skip the delete process if the files are not there.
 
Thanks
 
0 Kudos
Message 1 of 4
(2,987 Views)
 

The Delete VI will skip the process on its own. The simplest thing to do is to call it and ignore the error (for example by using the Clear Errors VI). Just make sure not to wire an error into it if you do this, because you will then clear that error.

As for some other tips regarding this VIs -

  • Using constant paths is often a bad thing, especially if your are going to build the code into an executable and\or move it to another computer. Getting the path to the desktop is done in Windows through a special function which you can call by using the Call Library Function node, or you can hold the base path in a global.
  • I suggest that unless absolutely necessary, you should not save your files to the desktop, but to another folder.
  • You should create error in and out terminals, so that you can control when the VI runs.
  • Giving it a less generic name is also a good idea, because LV can not hold 2 VIs with the same name in memory.

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here, here, here, here and here are a few you can start with and here are some tutorial videos. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
Message 2 of 4
(2,978 Views)

Well if the files aren't there, you'll get an error code 7 which is file not found. The easiest thing would be to just try the delete and check the error. You could use File/Directory Info and check for error code 7 from that before you try the delete, but I don't think it would make a difference. The delete file vi does this anyway before it attempts to delete.

Edit: you win tst, stars for you.

Message Edited by Marc A on 01-23-2007 02:14 PM

0 Kudos
Message 3 of 4
(2,973 Views)
I was getting the error and never having used much of the error handlers I completely forgot about them.  Saving it to the desktop is fine, I will be setting up the entire system before any of the test procedures are conducted by anybody else. 
 
Thanks for reminding me about something so simple.
 
 
0 Kudos
Message 4 of 4
(2,965 Views)