NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Trusted Enthusiast
Darren
Posts: 2,614

Darren's Weekly Nugget 08/28/2006

[ Edited ]
Here's an obscure one for everybody.  The In Range and Coerce function (Functions > Programming > Comparison palette in 8.0 and later) takes many different datatypes as inputs.  One of the datatypes it accepts is a path.  Prior to LabVIEW 8.2, the In Range and Coerce function would always return False for its "In Range?" output if you wired paths as inputs, no matter what the values of the paths were.  In LabVIEW 8.2, however, the function can actually do something with paths.  Specifically, it will check the ASCII values of the path characters and indicate whether or not the input is within the specified range.  Check out this screenshot:
 
 
As you can see, the value of "c:\blah4.txt" is determined to be "in range", i.e. in between the values "c:\blah1.txt" and "c:\blah5.txt".  I don't know when I would possibly use this behavior, but it's nice to know it's there.
 
-D

P.S. - Check out past nuggets here.

Message Edited by Darren on 08-28-2006 10:40 AM

Darren Nattinger, CLA
LabVIEW Artisan and Nugget Penman
Active Participant
Kevin_Price
Posts: 1,906
0 Kudos

Re: Darren's Weekly Nugget 08/28/2006

Also not sure if/when I'd use the behavior, but have not upgraded to 8.20 and am curious...
 
Does the "In Range?" operate like a pair of string comparisons?  In your example, would a path of "c:\blah314.txt" also be in range?
 
And for a more deeply-nested path, would it compare level-by-level, byte-by-byte, or only the final filename?
 
-Kevin P.
-- looking to hire? PM me...
Trusted Enthusiast
Darren
Posts: 2,614
0 Kudos

Re: Darren's Weekly Nugget 08/28/2006

For the case of identical parent paths, it does act like a string comparison, so yes, "c:\blah314.txt" would be in the range of "c:\blah1.txt" to "c:\blah5.txt".

For a more deeply nested path, I believe it compares byte-by-byte.  So "c:\blah\heyyou.txt" would in the range of "c:\a.txt" and "c:\c.txt".

Hope this helps,
-D

Darren Nattinger, CLA
LabVIEW Artisan and Nugget Penman
Trusted Enthusiast
chilly charly
Posts: 3,438
0 Kudos

Re: Darren's Weekly Nugget 08/28/2006



Darren a écrit: ... Hope this helps,

Sure !.. need 1 g of acetylsalicilic acid now...
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...        
Knight of NI
Ray.R
Posts: 10,171
0 Kudos

Re: Darren's Weekly Nugget 08/28/2006

The more I learn, the less I know...  -sigh- :smileyindifferent:

I never suspected that the range & coherce could (or would ever) work for paths.

Thanks Darren.

 

.
(starting to) See Life in a brand new way...

b* ^ )
Member
HJPhilippi
Posts: 61

Re: Darren's Weekly Nugget 08/28/2006


[...] As you can see, the value of "c:\blah4.txt" is determined to be "in range", i.e. in between the values "c:\blah1.txt" and "c:\blah5.txt".  I don't know when I would possibly use this behavior, but it's nice to know it's there.

I could imagine a scenario with VIs myVI_1.00.vi, myVI_1.01.vi, myVI_1.02.vi ... of different versions that are located in the same directory and wait to become loaded dynamically. Inside a possible caller, set the borders of the coerce function programmatically to the highest/lowest available VIs (assuming subsequent VI versions are all available) and the caller gets a VI loaded - whether requesting a VI name in range of the available VIs or a newer/older version that ist not there.

May sound a bit academic, but it can easily achieve some cool "injection" abilities of testing newer/older VIs without changing the caller's code, if this itself is prepared to handle dynamic VI calls! I know this could be achieved with other comparison functions, too - but one can say the same with the coerce function itself.
:smileywink:

Greetings,
Hans

Trusted Enthusiast
Darren
Posts: 2,614
0 Kudos

Re: Darren's Weekly Nugget 08/28/2006

Good use case, Hans!  One of my colleagues was questioning the validity of my nugget because he didn't think there was any time we could actually use the functionality.  But this one makes perfect sense...

-D

Darren Nattinger, CLA
LabVIEW Artisan and Nugget Penman
Trusted Enthusiast
TCPlomp
Posts: 3,085

Re: Darren's Weekly Nugget 08/28/2006

We use a timestamp as (part of) the filename, this coulde also be used as a filtering technique

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Knight of NI
Ray.R
Posts: 10,171
0 Kudos

Re: Darren's Weekly Nugget 08/28/2006

ALL your nuggets are excellent and important Darren.

I'm sure we'll make use of them in ways that you'd never imagine..  :smileyhappy:

.
(starting to) See Life in a brand new way...

b* ^ )
Active Participant
JeanPierre
Posts: 1,056
0 Kudos

Re: Darren's Weekly Nugget 08/28/2006

Is the comparison result dependant on the OS paths being case sensitive/insensitive?
In other words what is the result when x=C:\BLAH47.TXT on case insensitive paths on Windows?


LabVIEW, C'est LabVIEW

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page