LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Darren's Weekly Nugget 03/30/2009

Here's a quick tip when dealing with path data types.  Sometimes we have to deal with paths that have a value of <Not A Path>.  A value of <Not A Path> can be formed in many different ways...one way might be if you're trying to build a path with the Build Path function, and you accidentally wire an empty string into the "name or relative path" input.  If you want to test how your code handles a value of <Not A Path>, it's not as simple as typing "<Not A Path>" in a path constant or control.  You must operate click the little path symbol on the left side of the control/constant and change its value from "Valid Path" to "Not a Path":

 

 

If you try to type the text "<Not A Path>" into the path control/constant, LabVIEW treats that value as a relative path to a folder/file named "<Not A Path>", which is *probably* not what you were wanting to check.  The Not A Number/Path/Refnum? function is the easiest way to programmatically tell if a path value is truly <Not A Path>.

Message Edited by Darren on 03-30-2009 06:12 PM
Message 1 of 8
(7,120 Views)

That's good a tip, and reminds me of an interesting caveat that the Path to String and String to Path functions are not completely symmetric.  

 

For example, say you have a path with a value of <Not A Path>, the Not A Number/Path/Refnum? returns true.  BUT, when you convert this path to string, and then convert it back to the path type, the Not A Number/Path/Refnum? function no loner returns True!  This intuitively symmetric conversion does not preserve the <Not A Path> value.  As Darren pointed out, LabVIEW is now treating this as a folder/file named "<Not A Path>".

 

So if one anticipates that a path may have been converted from strings, it may be wise to check both Not A Number/Path/Refnum? and for the text "<Not A Path>".

0 Kudos
Message 2 of 8
(7,005 Views)

 Darren said:

You must operate click the little path symbol on the left side of the control/constant and change its value from "Valid Path" to "Not a Path"


 

As an integrator, we've gone almost exclusively to system controls to keep things from, dare I say, "looking like LabVIEW".  Any way to do what you've suggested with the System Path Control?  I can get the <Not A Path> type into the control, but not by copying / pasting.  Run the attached VI.  Notice that when you click in the first path control, it highlights "<Not A Path>".

 

-Jason

Message Edited by LabBEAN on 03-31-2009 02:05 PM

Certified LabVIEW Architect
TestScript: Free Python/LabVIEW Connector

One global to rule them all,
One double-click to find them,
One interface to bring them all
and in the panel bind them.
0 Kudos
Message 3 of 8
(6,950 Views)
The little path symbol isn't present on the system path control, so I guess the only way to get a true <Not A Path> as the value of your control is to use the Not A Path Constant and wire it to a local variable of the control.
0 Kudos
Message 4 of 8
(6,924 Views)

LabBEAN wrote:

I can get the <Not A Path> type into the control, but not by copying / pasting. 

I tried this, but both yielded the same results; I got False in both the cases. Smiley Sad

 

The only way I could make the System path control to accept the <Not A Path> value is by placing ite constant on the BD & then changing it into a control.

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 5 of 8
(6,866 Views)

Darren wrote:
The little path symbol isn't present on the system path control, so I guess the only way to get a true <Not A Path> as the value of your control is to use the Not A Path Constant and wire it to a local variable of the control.

 

Still easier way is to place a <Not A Path> constant on the BD & change it into a Control. Smiley Wink
- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 6 of 8
(6,865 Views)

D* wrote:

So if one anticipates that a path may have been converted from strings, it may be wise to check both Not A Number/Path/Refnum? and for the text "<Not A Path>".


Don't forget to also check for an empty path.

 

 

0 Kudos
Message 7 of 8
(6,853 Views)

 


parthabe wrote:

 

 I tried this, but both yielded the same results; I got False in both the cases. :smileysad:


 

I downloaded the VI I posted above on another machine and the top evaluates True.  To get the <Not a Path> type into the top control (versus the string in the bottom control), I replaced the System control with Modern, set <Not a Path>, and repalced the Modern with a System -- an alternate method that doesn't involve diagram mods.

 

-Jason

 


Certified LabVIEW Architect
TestScript: Free Python/LabVIEW Connector

One global to rule them all,
One double-click to find them,
One interface to bring them all
and in the panel bind them.
0 Kudos
Message 8 of 8
(6,809 Views)