Hidden Gems in vi.lib

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in SplitString.vi - VI returns empty array on pattern mismatch

Hi Folks,

I'm not sure if this issue is already discussed anywhre else in this group, but I was not able to find anything about it.

I just came across a bug or at least a misleading functionality inside the SplitString.vi from the hidden gems' advanced string palette.

If you specify any input string, and a pattern that does not match the input string, one would suggest, that the string is not splitted and gets returned completely as the first element in the output.

But due to a missing case inside the VI, the returned string-array is empty if the pattern did not match the string.
The only element in the array is always discarded in that case.
The element must only be discarded if the array holds more than one element. 

I've added a VI Snippet that shows the fixed version of the VI.

Can anyone of you verify that this is indeed a bug, or ist it just a flaw in the documentation?

Best Regards
Max

0 Kudos
Message 1 of 2
(5,534 Views)

@Crypt3x wrote:


Can anyone of you verify that this is indeed a bug, or ist it just a flaw in the documentation?


In my opinion, it's neither. If I give this VI a string, and a pattern that defines how to split the string, but the pattern is never found, then we can't split anything. This is also consistent (in my opinion) with the documentation, which says:

 

Split String - The array of elements between found instances of Split Pattern in Input String.

 

There were no instances of 'Split Pattern' found in 'Input String', so there are no "found instances" to return in the 'Split String' output.

0 Kudos
Message 2 of 2
(5,524 Views)