LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For a built LabView application, how do I code my VI so the name of the directory where it is located (e.g. its home directory) is automatically retrievable wherever I move it?

It's tedious and seems silly to recode my VIs only for the pathname constants. It would be nice to be able to move my executables to any directory/drive without worrying about where it is.
0 Kudos
Message 1 of 7
(2,613 Views)
Use the function "Current VIs Path"; it's located on the Functions pallete, File I/O sub pallete, File Constants sub pallete.
For example, suppose you build the VI "Main Rev1.vi" and call it "Main.exe" and save it in the folder "C:\LabVIEW EXEs\. If you run
"Main.exe" and it calls "Current VIs Path", it would return "C:\LabVIEW EXEs\Main.exe\Main Rev1.vi"
Message 2 of 7
(2,613 Views)
In addition to what McClellan said,

To get the file spec of the folder in a built app, you have to do a "stip path" twice.

The strip path only has to be done once for non-built.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 7
(2,613 Views)
Thanks for the tip. Although I will be tearing the pathname apart, this is certainly helps to shorten the task.
0 Kudos
Message 5 of 7
(2,613 Views)
Hi Ben,

I have a question relating to this answer you gave. New to Labview (Using 7.1) and I would like to get the path of a specific folder in my build app. This file contains my Help file I created. All works fine until I build my app and I have now realized that the problem is the file path constant that I'm using.

What is this "strip path"? Think I have to do this, but don't know how to go about it. Have found the 'current vi path' but this is not the complete answer, is it?

Thanks for any help or direction,
Madri
0 Kudos
Message 6 of 7
(2,613 Views)
The attached jpg shows you where to find the strip path function.

It will accept a path and will return two values. One is the stripped path, which is the passed path with the last part "stripped" off.

eg
"C:\FolderPath\VIName.VI" -> "C:\FolderPath"

Remember that the path of a VI in an executable differs from the development.

Unless you play special games, the path of a sub-VI in an executable is;

C:\FolderPath\VIName.exe\SubVIName.vi

So, you have to strip twice in an executable.


Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 7
(2,613 Views)