LabVIEW Idea Exchange

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

Make It More Obvious that Build Path Can Accept a Relative Path Input

Status: Completed

Available in LabVIEW 2020 and later. The 'name or relative path' input on the Build Path function now defaults to a path data type when the function is first dropped. It still accepts a string input if wired.

I've had enough!  Your code does not have to look like this:

all your paths.png

 

Or this:

even worse.png

 

You don't have to wire a string into Build Path's second input!  It can take a relative path just fine!  This is particularly helpful when building relative paths that involve climbing a directory structure.  But it's also useful for building hard-coded folder paths, or even just specifying a file name:

 

everything works.png

 

 

I've seen code that looks like the first two images way too often, so I propose the following:

 

  • Change the name of the second input of the Build Path function to 'relative path or name'.
  • Change the default data type of this input (i.e. what it looks like when unwired) to path instead of string.

The function will still work fine with string inputs (so existing code is fine), but this approach encourages developers to actually use the path data type when working with paths. You should kudo this idea if you have ever (1) written code that looks like the first two images, (2) needed to explain to someone that they can wire a path into Build Path's second input, or (3) gotten burned by multi-platform issues when somebody typed path separators into a string wired into Build Path.

14 Comments
Darin.K
Trusted Enthusiast

You are leaving out some of my biggest wishes for this function.

 

  • Expandable (That alone would greatly improve your first picture).  Same for Strip Path.  Think Build Array, Index Array except with Paths
  • Accept arrays of strings so I can stop using Array of Strings to Path with Relative wired
  • Shrink it, why 32x32px for a 2x1 connector pane?
  • Right-click option to automatically convert separators in the string to the system separator.  String manipulations of filenames and paths is still quite handy sometimes and this adds a little bit of system independence.

I have to think about changing the default type of the second input.  I am very used to the current type, but I know how annoying it is when you can not create a constant or control because the default type is not what you want (I want to use a string 90% of the time in Open VI reference).

Darren
Proven Zealot

All good ideas, Darin...and all worthy of their own Idea Exchange entries.  From what I know of the process, a bite-size chunk of an idea has a much better chance of getting implemented than the whole enchilada.  😉

crossrulz
Knight of NI

Darren,

  Looks like you have a nugget to start your "Weekly" nuggets back up with!  I've missed those.


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
Ray.R
Knight of NI

Soon we'll have Nugget Ideas 😄

 

Good one Darren!  Kudos!

justin.goeres
Member

I'll kudo this just for the reference.

Mr._Jim
Active Participant

You know what you doing...

 

 

(Yes, the improper grammar is deliberate, for those scratching their heads.)

Taggart
Trusted Enthusiast

Count me as one of the people writing it the first way (up until right now).  I always thought it was awkward.

Thanks for sharing!

Sam Taggart
CLA, CPI, CTD, LabVIEW Champion
DQMH Trusted Advisor
Read about my thoughts on Software Development at sasworkshops.com/blog
GCentral
wiebe@CARYA
Knight of NI

Just want mention that the "up the hierarchy" works for multiple levels:

"..\..\..\my dir\my file.txt"

steps up 3 levels. Very useful at times!

 

I'd really like some system paths resolvent (perhaps in a separate function or optional):

"%SYSTEM%\my dir" or "%TEMP%\my dir"

But that's yet another idea...

Darren
Proven Zealot
Status changed to: In Development
 
Darren
Proven Zealot
Status changed to: In Beta