From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Darin's Weakly Nugget - 01/04/11

Solved!
Go to solution

Lately we have been missing our weekly dose of useful information that you should know from an NI insider.  To help with that void, I offer a weekly dose of useless information that you should forget from an NI outsider.  Without further ado, here is the first installment of cool things I have found buried inside vi.lib.  These are cool VIs that for some reason just haven't made their way onto the palettes.

 

This week's cool VI:  "Match 1D String Array.vi"

 

Match1DArray.png

 

You'll find this guy in vi.lib/AdvancedString.  It looks like Search 1D Array, but there is a very useful twist, you can match a regular expression (regex), and not simply an exact string.  Another homebrew subVI of mine gets kicked to the curb.  I think my personal version has a cleaner BD, but they win the icon contest hands down.

 

What I also like is that there are multiple layers of coolness with this one.  If you look at the BD, you will see that they use Match Regular Expression_Execute.vi.  As I mention in my Regex Helper example, this is the business end of the Match Regular Expression XNode, and I often find the array outputs more useful than the individual submatches.  I also really like its partner which returns the offsets.

 

 

 

Message 1 of 25
(7,688 Views)

Darin, is "Weakly" a typo or are you implying that this week's nugget is somehow less pertinent than most???

 

EDIT:  Just realized you're not "that" Darin.  Hence the "weak" pun!!!  Smiley Tongue

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 2 of 25
(7,667 Views)

Bad puns are always a hazard with my posts.  Something else I may be known for is serving up a little "twist" with these posts.  In this case there is a bonus lesson about using vi.lib VIs, beware of bugs.  This VI contains a doozy, Kudo opportunity for the spotter.

0 Kudos
Message 3 of 25
(7,641 Views)

That was pretty punny darin.

0 Kudos
Message 4 of 25
(7,636 Views)
Solution
Accepted by topic author Darin.K

The bug is that if you pass in an empty array and a non-empty pattern, the loop will never stop because it is checking that the iteration count is equal to the array size minus 1, and not if it is greater than or equal.  This VI should use a For Loop with Break to avoid that situation (see this not-so-weakly nugget for more info).

Message 5 of 25
(7,607 Views)
I am lazy so I simply replace the equals with greater than or equal. Perhaps you can sneak in when nobody is looking and fix the official version....

 

 

Let's see in a few weeks if you can spot the bug in Bracket Balancing.vi as quickly.
0 Kudos
Message 6 of 25
(7,582 Views)

 


@Darin.K wrote:
I am lazy so I simply replace the equals with greater than or equal. Perhaps you can sneak in when nobody is looking and fix the official version....

I don't know if I'll be submitting any more changes into 2011 between now and release, but if I do, I'll wong in a fix for this.

 

0 Kudos
Message 7 of 25
(7,572 Views)

 


@Darren wrote:

 

I don't know if I'll be submitting any more changes into 2011 between now and release

And now we know why Darren keeps winning the coding challenges - he has seven months to practice. 😉

 


___________________
Try to take over the world!
Message 8 of 25
(7,507 Views)

Hi Darren,

 

while you are initiating the fix you also should note the bad German localization with inconsistant translations of "Match"...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 25
(7,493 Views)

Here's the fixed-up version of the VI I'm planning to include in 2011.  Let me know if y'all approve.

 

match_2011.png

Message 10 of 25
(7,094 Views)