LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

relative path utility

Dear friends at NI,

I need a utility which can convert absolute paths to relative paths. Its purpose is to replace the absolute paths used throughout the project with relative paths. It will be used wherever path constants are used, it will find the relative path to the same file i.e, its input will be an absolute path to a file and it will provide a relative path to the same folder hierarchy. Help required? (Some code (VI) would be just great!).

One more related question. Does the inclusion of relative paths in a project prove problematic which that project is to be converted into a executable?

And yet one more unrelated question. Is it possible to change my nick for this forum? If yes then how?

Thanks a lot! Have a very nice day!
0 Kudos
Message 1 of 19
(4,693 Views)


rashid19672008 wrote:

I need a utility which can convert absolute paths to relative paths. Its purpose is to replace the absolute paths used throughout the project with relative paths. It will be used wherever path constants are used, it will find the relative path to the same file i.e, its input will be an absolute path to a file and it will provide a relative path to the same folder hierarchy.

I'm not sure what it is you want to do, but you might wish to check out the OpenG Compare Two Paths.vi. I think what you actually want to do is to change your code so that you use relative paths. In this case, you can use something like this:
 
 
Again, OpenG has a very useful VI which does this and also allows you to append a relative path.
 
Your other question has a point - when building an EXE the VIs are placed inside it, so it does change things. Using code like shown above will solve that issue.

And yet one more unrelated question. Is it possible to change my nick for this forum? If yes then how?

Click the MyNI link at the top of the page, click on Modify Profile and change the alias.

___________________
Try to take over the world!
Message 2 of 19
(4,687 Views)

Paths are always a confusing issue for me. Where to save app data, user data, preferences, config data? Should I use relative or absolute path?  How do I deal with the file system being networked, and permissions?  There is one additional solution I use often: (WINDOWS ONLY) which is to use the CSILD values through the shell32.dll.  These are system independent (and even Win OS version) variables provided by M$ for common paths to save data.  Examples are Common App Data, Cookies and desktop.  Does any one else use this method?  It would be nice if additional path constants were provided by Labview to standardize (or at least provide a de facto method) for understanding where to keep data external to an application.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 3 of 19
(4,672 Views)
Check out the following VI:

<LabVIEW>\vi.lib\Utility\libraryn.llb\Compare Two Paths.vi

At least in LabVIEW 8.5 it's on the Advanced Functions palette, but I believe you can find it directly at the path listed above in older versions if it's not on the palette (but that's just a guess! 🙂 ).
Jarrod S.
National Instruments
Message 4 of 19
(4,651 Views)


falkpl wrote:

It would be nice if additional path constants were provided by Labview to standardize (or at least provide a de facto method) for understanding where to keep data external to an application.


Just wait a while. There's a whole bunch of threads there asking for feedback on this.
 
I do have VIs for calling the standard Windows paths, but I don't think I ever used them. Instead, I use the LabVIEW data directory. Not as nice, but built-in.

___________________
Try to take over the world!
0 Kudos
Message 5 of 19
(4,648 Views)


@falkpl wrote:

Paths are always a confusing issue for me. Where to save app data, user data, preferences, config data? Should I use relative or absolute path?  How do I deal with the file system being networked, and permissions?  There is one additional solution I use often: (WINDOWS ONLY) which is to use the CSILD values through the shell32.dll.  These are system independent (and even Win OS version) variables provided by M$ for common paths to save data.  Examples are Common App Data, Cookies and desktop.  Does any one else use this method?

Paul


I posted an example earlier (I know you've already done this) to help people link to common Windows locations with the method you described. Thought I'd link it here.
Jarrod S.
National Instruments
Message 6 of 19
(4,635 Views)
Thanks a lot tst, for such a detailed answer! Your VI was very educational (and useful). I have got OpenG toolkit installed. What's the difference between the Compare Two Paths.vi from NI and that from OpenG? And yes Compare Two Paths.vi solved the problem. Thanks a lot for that.

Thanks for giving a green signal to the use of relative paths if a project is to be converted into an exe.

Thanks for the alias problem too.
0 Kudos
Message 7 of 19
(4,621 Views)
Dear falkpl! Some of the stuff you talked about is quiet advanced. It would be very, very nice if you could provide some example VI / VIs , so that us, less gifted programmers, could also benefit from your expert programming knowledge.
0 Kudos
Message 8 of 19
(4,615 Views)
Yes, Jarrod S.! That VI certainly did solve the problem. Thanks a lot!
0 Kudos
Message 9 of 19
(4,612 Views)


C .DOT wrote:

Thanks for giving a green signal to the use of relative paths if a project is to be converted into an exe.

Just note that you have to decide what the path is relative to since that can change when you build an executable. If it's relative to the directory the top level VI is in, like shown in my example, you should usually be fine.

___________________
Try to take over the world!
Message 10 of 19
(4,608 Views)