LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comments: Optimizing Current Path

I have seen this type of thread more than once, and each reply (that I have noticed) seems to get a different VI or sub VI for the same solution. Thought I would start up a "optimize this" thread to get the best general solution. The one I made is smaller than most and should work within Windows, but relies on finding the first period in the path string. Does this have any obvious problems I have over looked or can this have unintended side effects on other platforms? Just curious...
Message 1 of 4
(2,876 Views)
Hi Chaos,

I haven't looked at any of the "other" posts that you are referring to, but I'll throw in my 2 cents worth. The only problem with your approach is (like you mentioned) it relies on there being a "." in the file name. Most of the time this will be okay since most files have a ".ext", but not all files have extensions. For this reason, I attached a VI written in 7.1 that reverses the string and then searches for the first "\". It then reverses the string back to make the relative path. I can't think of any circumstances where this would back fire (I can't think of any circumstances where there wouldn't be a "\" in the path).

Hope this helps!

Travis H.
National Instruments
Travis H.
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 4
(2,849 Views)
I use the approach illustrated in the attached jpg.

It keeps stripping the path until it finds a folder spec.

Works in development as well as in a built app.

Never tested it but it should be cross platform safe.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 4
(2,842 Views)
I'm for Ben's approach.

5 Stars.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 4 of 4
(2,827 Views)