rscott9399 Posted April 29, 2019 Report Share Posted April 29, 2019 Hi team I have a task before me and would like to do the following I have a file path. However, the path has more information in it then needed. In other words, it is drilled down a bit further then i need it to be. I need to some how strip the first bit of the path and take that information and feed it into the default space for an open file button. Does anyone have an recommendations on how to complete this task? Thanks Quote Link to comment
LogMAN Posted April 29, 2019 Report Share Posted April 29, 2019 If I understand you correctly, there is a path like "C:\a\b\c" and you need the "\b\c" in order to use it as "D:\default\b\c", right? Use this to check if one path is relative to another http://zone.ni.com/reference/en-XX/help/371361R-01/glang/compare_two_paths/ It returns the relative part which you can combine with your default path. I don't have access to LV right now, but this should be straightforward. Quote Link to comment
ShaunR Posted April 29, 2019 Report Share Posted April 29, 2019 You can use the Path to Array and then slice out whichever parts of the path you need and concatenate back again. Quote Link to comment
Darren Posted April 29, 2019 Report Share Posted April 29, 2019 5 hours ago, LogMAN said: If I understand you correctly, there is a path like "C:\a\b\c" and you need the "\b\c" in order to use it as "D:\default\b\c", right? I read it the opposite way, he has c:\a\b\c and just needs c:\a or c:\a\b. In those cases, you would use Strip Path. Quote Link to comment
ThomasGutzler Posted April 29, 2019 Report Share Posted April 29, 2019 (edited) Or Get Volume Info if you're only interested in the "C:\" part of it Edited April 29, 2019 by ThomasGutzler Quote Link to comment
LogMAN Posted April 30, 2019 Report Share Posted April 30, 2019 (edited) 8 hours ago, Darren said: I read it the opposite way, he has c:\a\b\c and just needs c:\a or c:\a\b. In those cases, you would use Strip Path. You are right, that is the standard way to do it, if you know how many elements to remove. You can also utilize the Common Path returned by the compare function depending on what you need. Edited April 30, 2019 by LogMAN Not being rude 1 Quote Link to comment
rscott9399 Posted May 8, 2019 Author Report Share Posted May 8, 2019 On 4/29/2019 at 11:48 AM, ShaunR said: You can use the Path to Array and then slice out whichever parts of the path you need and concatenate back again. This is the way i did it. Seems to work ok Broke it down into an array and then concat it back together with just the pieces i wanted. One caveat , when it strips it out, it looses the ":" colon in C drive, so concat a constant with it. Thanks for the suggestions. Been a few years since i have worked with LV and getting back into the swing Quote Link to comment
gleichman Posted May 9, 2019 Report Share Posted May 9, 2019 (edited) On 5/8/2019 at 8:15 AM, rscott9399 said: This is the way i did it. Seems to work ok Broke it down into an array and then concat it back together with just the pieces i wanted. One caveat , when it strips it out, it looses the ":" colon in C drive, so concat a constant with it. Thanks for the suggestions. Been a few years since i have worked with LV and getting back into the swing Is there a reason you're not using the actual "Strip Path" and "Build Path" functions? These allow you to manipulate the path, platform independent. No worries about slash direction and appending the root. Edited May 9, 2019 by gleichman Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.