LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
RayFarmer

Strip Path with recursive option

Status: Declined
The use case for this idea is already fulfilled by the use of path notation (e.g. ..\..\) with the Build Path function. Duplicating this functionality on Strip Path would provide minimal additional benefit.

It would be nice if the Strip Path function had a recursive option rather than having to string Strip Paths together or use an external loop.

 

 eg change from this:

strip_path.png

 

 

to this:

 

recursive_strip.png

 

 

regards

Ray

Regards
Ray Farmer
Download All
15 Comments
Broken_Arrow
Active Participant

Kudos, but this would need to be used with caution, if the path level were ever to change. You could program-in a robust Expected Path? checker, which might traverse through stripped paths until the Expected Path is found.

Richard






Dragis
Active Participant

I could be wrong, but I thought you could already use build path with a string of "../../../.." just like you can from the shell.

SteveChandler
Trusted Enthusiast

You can use build path but I think this is cleaner. Kudos!

=====================
LabVIEW 2012


altenbach
Knight of NI

What should happen if it bangs into the root folder after a few steps? Should it stop early, continue, or return an error?

(currently, the function does not even have error IO). Should zero be allowed, returning the same path?

 

You could just wrap a FOR loop around it and keep the path in a shift register. Currently, it returns the following as a function of N:

 

0.  C:\alpha\beta\gamma\myfile.txt

  1. C:\alpha\beta\gamma
  2. C:\alpha\beta\
  3. C:\alpha\
  4. C:\
  5. (blank)
  6. <Not A Path>
  7. <Not A Path>
  8. <Not A Path>
  9. ...


SteveChandler
Trusted Enthusiast

If it doesn't work like the results that Christian shows using a shift register and loop then I'm going to take my kudos back Cat LOL

=====================
LabVIEW 2012


PhillipBrooks
Active Participant

By Darin.K

 

http://forums.ni.com/t5/LabVIEW/Strip-path-multiple-times/td-p/1407434

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

David_L
Active Participant

This is one of those ideas that makes you wonder how nobody thought of it years ago..  I think it will help make File I/O code much cleaner and I'm pretty sure I'd use it almost every day.

RayFarmer
Trusted Enthusiast

you could also include a return boolean or two to handle the empty path or Not a Path. As to whether Error Cluster(s) are included and the function returns errors, it's a good point. How many times do we wrap functions up so that there is an error in / error out.

 

Regards
Ray Farmer
Knight of NI

While I see the functionality as being useful is some cases, changing core functions is always problematic. Especially if you're talking about adding an integer input and error I/O. What would happen if you try to downconvert code that uses this new version? Perhaps creating a separate function, such as "Strip Path (Recursive)" would be better. If you try to downconvert code that uses this function it could be replaced with a subVI. Whether or not the downconversion mechanism could do that is a different question though.

GuenterMueller
Active Participant
Replacing it with a subVI when downconvertinng sounds reasonable. This downconverted subVI could be broken (by intention) and the block diagram could contain a comment like "cannot downconvert Strip Path Recursive".