LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Single Path accessible for VI at all levels

Solved!
Go to solution

Hello, 

 

I am developing a calibration application which utilize about six different write to csv and read csv VIs. They access different log files in the same location. I find it very time consuming to update path for each Vi when I change the folder location. I prefer not to use a string/Path control since these write/read csv VIs are at different levels in the application. Currently I use a path constant for each VI. and I was wondering if there is a better way to do this. I tried having a string control as a global variable. But the string does not update in each write/access to csv VI whenever I change string path in the global variable. Please find attached picture. The one circled is the one I try to keep consistent for all write/access CSV VIs. 

 

Thanks

 

FLiu

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

I'm not entirely sure I understand your question.  So I'll make some comments:

  1. You can use the File Constant "Default Data Directory" to specify the Folder, independent of anything else, where your Log files will live.  Note that this is usually the folder LabVIEW (by default) saves your VIs.  If you want a folder relative to this folder, you can, of course, construct that, too.
  2. You can create a sub-Folder (or filename element) from the name of the VI that is doing the Saving, or from the top level VI (if you want to make the files "program-specific".  Use Call Chain to get the name of the VIs (I don't remember if this gives you the .vi extension as well, but you can remove that with String functions).
  3. When you open a File for writing, you can first see if the file already exists.  If so, you can "add a numeric extension" and try again.  That is, try to see if "My Output.txt" exists.  If so, look for "My Output.000.txt".  If that exists, try "My Output.001.txt".  You'll notice I'm using 3-digit extensions to help with sort order in a directory listing -- if you think you'll have more than 1000 files, you can go to 4 digits (or more) ...

I hope this suggests ways to simplify your file-naming situation.  If I've missed your point, please explain ...

 

Bob Schor

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

These are very helpful thanks ! 

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