LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

determine relative path for open vi reference

I would like to use the open vi reference feature to call code relative to either the main vi or the executable depending on the context that it is run. What is the most efficient way to access the path if I only know the base name?

0 Kudos
Message 1 of 3
(3,052 Views)

I'm not sure I understand exactly what part you are having trouble with but I like to use the Current VI Path function and build/strip path.  You can use a property node to figure out whether the VI is running as an executable or the conditional diagram disable structure to do the same thing.

 

http://zone.ni.com/reference/en-XX/help/371361M-01/glang/current_vis_path/

 

You can also use the Application Directory VI which will output a different path depending on whether you are running the standalong VI, from a project, or as part of an executable.

 

http://zone.ni.com/reference/en-XX/help/371361M-01/glang/application_directory/

Matt J | National Instruments | CLA
0 Kudos
Message 2 of 3
(3,039 Views)

I highly recommend using the Application Directory for building paths to configuration files and files outside of the executable.  This avoids the whole mess of trying to figure out if you are in the executable or development environment, simplifying your code.

 

If you are trying to find VIs that are inside of the executable, use the Current VI's Path to build the location.  Since 2009, the executable keeps a directory structure, so relative paths do not change between the development environment and the executable.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 3
(3,024 Views)