LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

<Not A Path> Comparison not working.

I ran across this tonight, and it seems a little weird to me. I have a path that shows as "<Not A Path>" in probes and in the control/indicator, but the NaN/Path/Refnum? function returns false. I suspect it has something to do with how this path was created (I used path to string, some string operations, and then string to path on it), but I would still expect the comparison to return True. Any thoughts or insights? I used Flatten to String to look at the path, and it is clearly different from the Not A Path Constant. I can use File/Directory Info instead, and then check for an error, but this is annoying. The vi is saved in LV8.6.

 

Chris

 

 

Message Edited by C. Minnella on 02-05-2009 06:39 PM
Download All
0 Kudos
Message 1 of 10
(3,698 Views)

I have seen similar things before. You can type "<Not A Path>" into a path control, but it's not really <Not A Path>. If I remember right, I think I have seen this as far back as V7. I would call it a bug.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 10
(3,684 Views)

See that tiny little path symbol (the two offset squares connected by a line) on the left side of the path control?  Operate-click on that...you can set it to "Not A Path".  This is how you specify that the value in a Path Control is Not a Path.  Just typing a string of "<Not A Path>" into the control won't cut it.

 

-D

 

P.S. - Same trick works on Path Constants.

 

P.P.S. - Is this worth a nugget?

Message 3 of 10
(3,677 Views)

Yeah.

 

if you wire the "Path Type" Function to the path you'll see that the string "<Not A Path>" is type=1 (relative path), the real "<Not A Path>" is type = 2 (well, "Not A Path")

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 4 of 10
(3,662 Views)

Chrisger wrote:


"<Not A Path>" is type=1 (relative path), the real "<Not A Path>" is type = 2 (well, "Not A Path")


You can even see this in the both string indicators.

 

"<Not a Path>" is really invalid on Windows and as far as I know on Linux. So the primitive "String to Path" should create an invalid path (type=2).

Normally you use the system dialogs to create a file but in other use cases you do that indirectly. Think of a test person how enters an alpha numerical article number and you create a folder somewhere based on the article number. A short check is "String to Path" and check for a relative path.

Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 5 of 10
(3,650 Views)

Thanks guys. I think the grand solution is to avoid the use of Path to String and String to Path, or to use a little more robust error checking on paths when those functions are used. It seems that an invalid path will always be converted to a relative path using those functions. Would it be unreasonable for the String to Path function to just do a search of the input string for "<Not a Path>" when converting to determine the path type (I guess that could be a valid relative path on some platforms..)? Thanks Darren, I never knew that you could change the path type by using the operate tool on the path control. I can't really think what I'd use that for except maybe troubleshooting, but it is a neat little trick. 

 

I ended up solving my problem by just checking the base path before it was converted to a string instead of after it was converted back to a path. Any path that orginates from a <Not a Path> base path will end up being <Not a Path>. This won't catch the situation where a valid base path is invalidated by my string operations, but that is not an issue in this application.

 

Chris

0 Kudos
Message 6 of 10
(3,618 Views)

Yes, I think it's a good idea to avoid the string/path conversions and stick with the path data type when possible.  You run the risk of writing platform-dependent code when you start dealing with paths as strings.

 

If you still need some help coming up with the best way to work with paths, post some more details to the thread and we'll help.

 

-D

0 Kudos
Message 7 of 10
(3,610 Views)
<it's worth a nugget>
0 Kudos
Message 8 of 10
(3,594 Views)

Darren wrote:

 

P.P.S. - Is this worth a nugget?


Here's an example of the nugget:

 

Message Edited by JoeLabView on 02-06-2009 02:58 PM
Message 9 of 10
(3,590 Views)

JoeLabView wrote:
<it's worth a nugget>

Duly noted.  It's in the hopper now.

 

-D

0 Kudos
Message 10 of 10
(3,588 Views)