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.
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.
01-04-2011 12:47 PM
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"
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.
Solved! Go to Solution.
01-04-2011 01:28 PM - edited 01-04-2011 01:31 PM
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!!!
01-04-2011 02:28 PM
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.
01-04-2011 02:34 PM
That was pretty punny darin.
01-04-2011 03:22 PM
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).
01-04-2011 03:52 PM
Let's see in a few weeks if you can spot the bug in Bracket Balancing.vi as quickly.
01-04-2011 04:07 PM
@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.
01-05-2011 02:04 AM
@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. 😉
01-05-2011 02:34 AM
01-17-2011 04:26 PM
Here's the fixed-up version of the VI I'm planning to include in 2011. Let me know if y'all approve.