03-30-2009 06:11 PM - edited 03-30-2009 06:12 PM
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>.
03-31-2009 08:23 AM
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>".
03-31-2009 01:04 PM - edited 03-31-2009 01:05 PM
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
03-31-2009 01:59 PM
04-01-2009 01:24 AM
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.
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.
04-01-2009 01:33 AM
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.
04-01-2009 02:45 AM
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.
04-01-2009 09:39 AM
I tried this, but both yielded the same results; I got False in both the cases.
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