LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Path questions

I have the following questions about paths.

 

1. For LabVIEW version newer than 8.x, the path for a vi that is compiled into an exe is preserved.  I understand that it will prevent naming conflict inside the exe.  However, it is a pain to do build path and strip path.  Is there a better way?  I find myself having the LabVIEW 8.x file layout checked a lot of times when I complied an exe.

 

2. It seems like the Current VI's Path node is always preferred over the Application Directory node.  Is there an instant where it is better to use the Application Directory node?  

 

3. Are there any strategy to keep build and strip path from getting out of control?  Some codes use so many build and strip path, and they make it very hard to tell what folder is being accessed.

 

4. When would you use a relative path over an absolute path or vice versa?

 

 

 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 15
(3,117 Views)

In 95% of all cases, i use "Application Directory".

Most obvious reason: I call sources located outside of the EXE, so i don't have to distinct between the application being compiled into an EXE or if i still work on development.

In the rest of all cases (5%), i will "stay" in my EXE. So i take "Current VI path", strip the name and maybe one or two paths, then add the new relative path. I never use this "to leave the EXE", so the sources are (if organized in a well structured project folder) equally placed in development as in EXE. So, here as well, i have not to distinct between EXE or development.

 

If having to distinct EXE from development, you can use "Application Kind" (App.Kind) in VI Server to check for the environment:

AppKind.PNG

 

Norbert

 

EDIT: Relative paths are always superior to absolut paths except if you have to change the drive/partition.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 15
(3,077 Views)

I will second pretty much everything Norbert said.

 

1.  Use the newer format.  It works better when trying to dynamically call VIs.

2.  I use the Application Directory so much more than the Current VIs Path, mostly because I'm trying to find a lookup table or the like.

3. One trick is to use ".." in your build path.  Using ".." as a folder will move up a folder.  So you can do some fun stuff with that.  For instance, application path is "C:\foo\bar\blah".  You can use "..\blah1" in the relative path and the result will be "C:\foo\bar\blah1".

4. 99% of the time, I use relative paths simply because projects get moved around.


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
Message 3 of 15
(3,059 Views)

Microsoft have been trying to encourage developers to separate program files, user files, and program data files since Windows XP. In Vista they began to mildly enforce it; depending on whether the program is being run by an administrator or as a standard user, the program may not be allowed to write to the Program Files directory.

 

I almost always use the Get System Directory VI, which will correctly resolve the path depending on the system it is running on. i.e. Win XP, Win 7, MacOS, Linux etc.

App Data Directory.png

_____________________________
- Cheers, Ed
Message 4 of 15
(3,044 Views)

Norbert,

 

You said that you take "Current VI path", strip the name and maybe one or two paths, then add the new relative path. I never use this "to leave the EXE", 

 

Why do you need to strip the path from currenet VI path if you don't use current vi path to leave the exe? It seems to me that the two statements conflict. 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 5 of 15
(3,045 Views)

Crossrulz,

 

How is the newer format better when trying to dynamically call VIs?

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 6 of 15
(3,041 Views)

@jyang72211 wrote:

Norbert,

 

You said that you take "Current VI path", strip the name and maybe one or two paths, then add the new relative path. I never use this "to leave the EXE", 

 

Why do you need to strip the path from currenet VI path if you don't use current vi path to leave the exe? It seems to me that the two statements conflict. 


I sometimes require to strip a "folder" or two from current VIs path because the VI is in a subfolder within the project. Since the EXE keeps that subfolder, navigation between subfolders in the EXE require strip path.

But i never go that high by stripping that i strip the name of the EXE....

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 7 of 15
(3,041 Views)

Oh, I was confused.  I kept thinking about the file layout of an exe for 8.x.  For the new LabVIEW version, it makes perfect sense.

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 8 of 15
(3,037 Views)

@jyang72211 wrote:

Crossrulz,

 

How is the newer format better when trying to dynamically call VIs?


Because the newer format keeps the directory structure (to a degree) inside of the EXE.  Therefore any relative paths between VIs will not change between the development and run time environments.


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
Message 9 of 15
(3,030 Views)

Oh, I didn't realise we were navigating around inside the EXE. To amend my post:

- I will use relative paths within the EXE, for example to read dynamic VIs that were shipped in the main build.

- Almost anything that involves writing to file is resolved through the Get System Directory VI

- Additional resources like plug-ins are saved to the Application Data Directory, again read with the Get System Directory VI

_____________________________
- Cheers, Ed
Message 10 of 15
(3,030 Views)