Jump to content


Photo
- - - - -

LV2010 weirdness


  • Please log in to reply
10 replies to this topic

#1 mike5

mike5

    Very Active

  • Members
  • PipPipPip
  • 159 posts
  • Location:Slovenia
  • Version:LabVIEW 2010
  • Since:2009

Posted 14 October 2011 - 08:18 AM

Here is a little something I found today:

LV2010-WTF.png

and the VI that demonstrates it. Run this, and

String 1="bug"
String 2="z"

Change zip->yip and String 1 becomes "y".

Nice, ha?

Br, Miha

The workaround is "a".."z", "z"

:frusty:

Br, Miha

Attached Files

  • Attached File  bug.vi   7.33K   51 downloads

Close the world, txEn eht nepO.

#2 crossrulz

crossrulz

    Extremely Active

  • Members
  • PipPipPipPip
  • 254 posts
  • Location:Cincinnati, OH
  • Version:LabVIEW 2011
  • Since:2004

Posted 14 October 2011 - 12:10 PM

It's actually not a bug. The case structure is just not range inclusive for strings.

#3 mike5

mike5

    Very Active

  • Members
  • PipPipPip
  • 159 posts
  • Location:Slovenia
  • Version:LabVIEW 2010
  • Since:2009

Posted 14 October 2011 - 12:19 PM

It is a bug, since either it is or it isn't. But this one isn't just in the first case. In case of a constant it is.

Br, Mike

Also, it also works for any string beginning with "a", so my guess is still it's a bug.

Br, Miha
Close the world, txEn eht nepO.

#4 Saverio

Saverio

    Enough LAVA to be dangerous

  • Members
  • PipPipPip
  • 144 posts
  • Version:LabVIEW 8.2
  • Since:1994

Posted 14 October 2011 - 01:18 PM

From the LabVIEW Help:

For numeric ranges, specify a range as 10..20, meaning all numbers from 10 to 20 inclusively. You also can use open-ended ranges. For example, ..100 represents all numbers less than or equal to 100, and 100.. represents all numbers greater than or equal to 100. For string ranges, a range of a..c includes all strings beginning with a or b, but not c. A range of a..c,c includes the ending value of c.

Not a bug.



#5 Samapico

Samapico

    More Active

  • Members
  • PipPip
  • 35 posts
  • Location:MontrĂ©al, QC
  • Version:LabVIEW 2010
  • Since:2009

Posted 14 October 2011 - 01:52 PM

How does that explain string 2 being "z" ? The two results appear to be contradictory... According to the help, String 2's result would appear to be a bug...


But I'm still wondering: why would they make string ranges non-inclusive? In what case is it useful? Considering numeric ranges are inclusive, this really seems to be counter-intuitive.

Edited by Samapico, 14 October 2011 - 01:54 PM.


#6 Saverio

Saverio

    Enough LAVA to be dangerous

  • Members
  • PipPipPip
  • 144 posts
  • Version:LabVIEW 8.2
  • Since:1994

Posted 14 October 2011 - 02:12 PM

Sorry, I was explicitly referring to the "inclusiveness" in terms of whether it's a bug or not. You seemed to be implying that the non-inclusiveness is a bug. In actuality, the bug is that in the second case, LV 2010 is not behaving correctly. When you wire in a constant it does one thing, but when you wire in an output of a string function it does something else. That seems to be a compiler issue. In LV 2011 it behaves correctly, i.e., according to the documentation. You may disagree with it, but that does not make it a bug. ;)

I do not know the reason why the string range was made non-inclusive. That's something you'd need to ask NI. You can always lobby to have the behavior changed by posting an idea in the LabVIEW Idea Exchange.

#7 Darin

Darin

    Very Active

  • Members
  • PipPipPip
  • 160 posts
  • Version:LabVIEW 2009
  • Since:1992

Posted 14 October 2011 - 04:36 PM

Just slap an 'Always Copy' node after the constant in the second case and it is all good (LV10). They should probably change the icon of that function to a band-aid. (Of course the number of places you need this is supposedly declining, but it is still good to know for those of us stuck with old versions).

#8 mike5

mike5

    Very Active

  • Members
  • PipPipPip
  • 159 posts
  • Location:Slovenia
  • Version:LabVIEW 2010
  • Since:2009

Posted 14 October 2011 - 05:08 PM

From the LabVIEW Help:

For numeric ranges, specify a range as 10..20, meaning all numbers from 10 to 20 inclusively. You also can use open-ended ranges. For example, ..100 represents all numbers less than or equal to 100, and 100.. represents all numbers greater than or equal to 100. For string ranges, a range of a..c includes all strings beginning with a or b, but not c. A range of a..c,c includes the ending value of c.

Not a bug.


Thanks. I guess it's just one of those things where you never actually read the docs, because you use the thing every day.

Br, Mike


Close the world, txEn eht nepO.

#9 Gary Rubin

Gary Rubin

    The 500 club

  • Members
  • PipPipPipPipPip
  • 612 posts
  • Location:Northern Virginia, USA
  • Version:LabVIEW 8.6
  • Since:1997

Posted 17 October 2011 - 04:01 PM

So I can make all my bugs go away by simply describing the behavior in mydocumentation? Awesome! ;)

#10 Saverio

Saverio

    Enough LAVA to be dangerous

  • Members
  • PipPipPip
  • 144 posts
  • Version:LabVIEW 8.2
  • Since:1994

Posted 18 October 2011 - 08:40 PM

So I can make all my bugs go away by simply describing the behavior in mydocumentation? Awesome! ;)


Who knows, maybe NI meant it to work that way. Inquiring minds would like to know...

#11 Darin

Darin

    Very Active

  • Members
  • PipPipPip
  • 160 posts
  • Version:LabVIEW 2009
  • Since:1992

Posted 18 October 2011 - 09:17 PM


Who knows, maybe NI meant it to work that way. Inquiring minds would like to know...


For better or for worse (separate discussion), LV has no notion of a 'char', only strings or byte arrays. The selector has to be interpreted as a string, and therefore one of the limits must not be inclusive (upper one makes slightly more sense). Otherwise you would sometimes need to write the "biggest" string which starts with b, is it bzzz or bzzzz or bzzzzz.... This is also what currently precludes floats from the selector.

I wish we could specify the inclusiveness of either bound using standard '[' versus '(' conventions. You could then write ["a".."c"] or ["a".."c") or ("a".."c"]. This would also allow floats to be used which would be very cool IMO, you could have NaN, +Inf, -Inf, [0..3), [3..6), cases.