LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Path Woes

While working on some code that processes paths, I ran into a perplexing bug (in my code).  It took me quite a while to figure it out.

Paths were being generated that looked fine, but wouldn't work.

The attached code illustrates what was happening (though it wasn't so obvious in my real code).  Run the VI.  The Bad Path "looks" exactly the same as the Good Path.  But they're not the same.  The array indicators show what went wrong.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 1 of 33
(1,844 Views)

Is there any benefit/difference to operating with arrays on path, rather than with strings?

 

I usually operate with strings and then concatenate them to a full path

0 Kudos
Message 2 of 33
(1,829 Views)

@AeroSoul wrote:

Is there any benefit/difference to operating with arrays on path, rather than with strings?

 

I usually operate with strings and then concatenate them to a full path


With arrays, each path element is a separate element in the array.

With strings, path elements are separated by delimiters that are specific to the file system ("\" in Windows).

"If you weren't supposed to push it, it wouldn't be a button."
Message 3 of 33
(1,823 Views)

@paul_cardinale wrote:

@AeroSoul wrote:

Is there any benefit/difference to operating with arrays on path, rather than with strings?

 

I usually operate with strings and then concatenate them to a full path


With arrays, each path element is a separate element in the array.

With strings, path elements are separated by delimiters that are specific to the file system ("\" in Windows).


Do you index the array into each "Build Path" primitive?  That's how I do it.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 33
(1,819 Views)

As a side note, these can come in handy sometimes:

vi.lib\Utility\sysinfo.llb\Get File System Separator.vi

vi.lib\Utility\sysinfo.llb\Get File System Root Name.vi

vi.lib\Utility\sysinfo.llb\Get File System Parent.vi

"If you weren't supposed to push it, it wouldn't be a button."
Message 5 of 33
(1,815 Views)

@billko wrote:

@paul_cardinale wrote:

@AeroSoul wrote:

Is there any benefit/difference to operating with arrays on path, rather than with strings?

 

I usually operate with strings and then concatenate them to a full path


With arrays, each path element is a separate element in the array.

With strings, path elements are separated by delimiters that are specific to the file system ("\" in Windows).


Do you index the array into each "Build Path" primitive?  That's how I do it.


Not sure what you mean.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 33
(1,810 Views)

I didn't have LabVIEW on this computer, so I assumed you had pieces of the path in an array and to build the path you just indexed the array.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 33
(1,804 Views)

ah, so it's more for universality among different OS.

I operate exclusively on windows, so i usually just use strings.

0 Kudos
Message 8 of 33
(1,793 Views)

@AeroSoul wrote:

ah, so it's more for universality among different OS.

I operate exclusively on windows, so i usually just use strings.


Lacking a crystal ball, I don't assume that my code will never be used with a different file system; I consider such an assumption to be bad coding practice.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 9 of 33
(1,787 Views)

@paul_cardinale wrote:

@AeroSoul wrote:

ah, so it's more for universality among different OS.

I operate exclusively on windows, so i usually just use strings.


Lacking a crystal ball, I don't assume that my code will never be used with a different file system; I consider such an assumption to be bad coding practice.


Try this improved method


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 33
(1,779 Views)