LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can you do Greater/Less Than args in case statements?

I'm having trouble finding anything in the help about using a "<0" or ">0" in a case statement- and when I try to type it into the cases it turns red and errors.  I know I can do "0.." or "..0" but that includes zero in that frame...

 

Story is, I have a value coming in, if it's negative I need to load fileA.txt, if positive, load fileB.txt, if it's zero (would be default case) it does something else.  I know there's gotta be a simple way of doing this, I havent finished my coffee yet and maybe I'm bein too quick to post here (but im way behind Robot Sad)... in the mean time I might just do 3 different case statements haha...

 

thx

-pat

0 Kudos
Message 1 of 4
(4,061 Views)

First, case statements only handle integers.  If your input is a float or double, you need to compare before the case.  If you have integers, the solution is fairly easy. For <0 use "..-1".  For >0 use "1..".

Message 2 of 4
(4,051 Views)

You could also simply use the Sign function. NOTE, however, that you might have problems with it determining whether a number is really zero due to the way floating point numbers are stored in computers.

Message 3 of 4
(4,042 Views)

Good info! Thanks you very much!

 

kudos Smiley Wink

 

-pat

0 Kudos
Message 4 of 4
(4,034 Views)