10-05-2015 09:50 AM
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?
10-05-2015 10:24 AM
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/
10-05-2015 10:42 AM
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.