OlivierL Posted February 10, 2017 Report Share Posted February 10, 2017 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 Quote Link to comment
infinitenothing Posted February 10, 2017 Report Share Posted February 10, 2017 (edited) It's weird behavior for a weird use case but it appears to do what it says it's going to do. https://zone.ni.com/reference/en-XX/help/371361M-01/lvhowto/case_selector_values/ Edited February 10, 2017 by infinitenothing 2 Quote Link to comment
OlivierL Posted February 15, 2017 Author Report Share Posted February 15, 2017 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... Quote Link to comment
tlerunner Posted February 15, 2017 Report Share Posted February 15, 2017 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! Quote Link to comment
Rolf Kalbermatter Posted March 8, 2017 Report Share Posted March 8, 2017 (edited) 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 March 8, 2017 by rolfk Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.