Jump to content

String case selector "Range"


OlivierL

Recommended Posts

Hi,

I wonder if this is a bug of LabVIEW or if I misinterpret the "Range" function in the case selector.

In the VI Attached, a string is used to select a case in a Case Structure. there is a case for "0".."9" that LabVIEW accepts but if you input the string "9", LabVIEW executes the Default case. If you change the case to "0".."9", "9", then first of all LabVIEW doesn't return an error saying that values are not unique and it behaves as expected if you pass the string "9". Can anyone explain why LabVIEW would exclude the last value in the range?

Cheers,

Olivier
 

Last Character Excluded From Range.vi

Link to comment

Change the string input to a number and update the case structure and you get the behavior you expect.  Interesting that a string case structure with a range only checks the first character of the input.  Try 1234 in your VI.

I did not know this, been using LabVIEW for 20 years.  Learn something new every day, thanks!

Link to comment
  • 3 weeks later...
On 2/15/2017 at 6:25 AM, OlivierL said:

wow, you are correct. That is how the feature is documented and implemented! Thanks for posting this. I can't understand why NI chose that implementation but it probably goes back a couple of decades and it might not have been intentional...

It's simple: How would you want to implement a multi selection case structure when using strings, that should select between "a".. "f" and "f" .. "z"?

One of the two ends has to be non-inclusive if you want to allow "flying" to match the selection too. It would be unpractical to let the string selection only work if the incoming string matches exactly (eg. "f1" would not match anything in above sample!.

Edited by rolfk
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.