I am attempting to do something fairly simple in LabView but it seems that there must be an easier or more elegant way than the way I am doing it.
I have the main .vi running in c:\programs and it calls another .vi in the same directory. In this subVI the program creates/replaces tags.dat in the c:\programs\data directory. I want the file to be created if it doesn't exist or replaced if it does exist. If the \data directory doesn't exist, I want it created. And also I want the .vi to run in any directory and as a .exe or as a .vi. This is what I am doing to accomplish this:
1) Use App.kind, "Current VI's Path" and a case statement to strip once if it is "development system" and twice if it is "run-time system".
2) Then use "LIST Directory" and a "For Loop" to look for "data" directory. If it exists, do nothing, if it does not use "New Directory" to create it.
3) Use "LIST Directory" and a "For Loop" to look for "tags.dat" in \data directory. If it exists use "Delete" to delete the file, if it does not exist, do nothing.
4) Use "Open/Create/Replace File" with it set to "create or replace" to create tags.dat in the \data directory.
Shouldn't the "Delete" file VI delete a file if it exists, but do nothing if it does not exist? Instead, if the file doesn't exist, it causes an error. The same goes for the "New Directory". It should create the new directory, unless it already exists. Also is there a way "open/create/replace" with it set to "create or replace" will not prompt the user to ask them if they want to delete the file (if it already exists)? This is why I have to look for the file first, then delete it if it exists.