Jump to content

Case Selector range Notation


Recommended Posts

Absolutely, I find it weird. It doesn't match the Integer notation and even more so it includes the first item but not the last. I was using to match numeric 0-9 which yes you could use a regex but its a range 0-9 simple case statement should work. its weird to put "0"..":" I had to reference my ASCII table just to know which one to use. And I do agree it is stated in the reference above, but I generally dislike inconsistency especially with logical concepts that should be transferable; just because something is known doesn't mean it cannot be incorrectly inferred or forgotten. That being said, I would really like to know the rationale, however if there has to be a discussion it doesn't bode well for the "feature".

Link to comment

With integers you can do ranges like <=3 and >=4, and there is no gaps.  But with non-integers you cant: <=3 and >=4 misses out all numbers between 3 and 4.  But you also can't do <=4 and >=4, since then 4 falls in both ranges.  So you have to do <4 and >=4, and thus have a range (<4) which does not include its endpoint, confusingly.

Strings are actually more like floats, than like integers; between "c" and "d" is "ca", "cz", "czzzzzzzzzzzzzzzzzz", etc.  Even if "a..c" included "c", it would not include "ca".  There is no way to do non-overlapping-but-complete ranges with strings without not including one endpoint.  Unfortunately, people intuitively think of "a..c" as anything starting with "a" to "c", but it isn't.

Link to comment

I've been doing C++ recently after a very long time. I'd almost forgotten how much pain is circumvented with LabVIEW case structures.

With no multi-line literals (can't just paste a key into a page). No "switch" [case statement] with strings.....period. Case sensitive whether you like it or not. Thank god it's almost over and then I can control it with LabVIEW.

Link to comment

I see what your saying now. When looking at a single ASCII character it would make sense to include the last point just like they do with integers. however there is not a character type only a character array type (string), and in an effort to make the case statement ranges more useful in the string realm they made a notation that is essentially a begins with function. (regex would probably be more useful/but slightly slower). This does explain it a bit though.

@ShaunR I am also glad it is not C++. 

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.