LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Case question

I know how to do simple case structures ie True and False. Suppose
however I have an integer N and I have three possibilities:

Case1

if N>5
it does one thing
case 2

if N<-5
it does something else
case 3

if -5<5
it does a third thing.

How to do this in the simplest way?

Thanks

Tom
0 Kudos
Message 1 of 8
(3,212 Views)
Hi Tom,

Attached is a V7.0 example of a simple solution to your problem.

Hope this helps,

Nick
0 Kudos
Message 2 of 8
(3,212 Views)
Hi,

You can click in the white box where it says "TRUE", while the I cursor is
selected (with tab).

In this box you can now put "1,2,3", "5..", "..5", etc. If there is a number
missing (e.g. two cases : "..5", "8.."), you'll have to make a default case.

The case always selects including the number (floating point numbers are
converted to integer). So in you example you need :Case 1: "6..", Case 2:
"..-6", Case 3: "-5..5". This does not exactly what you want but: "N>5",
"N<-5", "-5=
Regards,

Wiebe.

"Tom" wrote in message
news:3F8A2BE0.3CFC26A1@nOpam.com...
> I know how to do simple case structures ie True and False. Suppose
> however I have an integer N and I have three possibilities:
>
> Case1
>
> if N>5
> it does one thing
> cas
e 2
>
> if N<-5
> it does something else
> case 3
>
> if -5<5
> it does a third thing.
>
> How to do this in the simplest way?
>
> Thanks
>
> Tom
>
>
0 Kudos
Message 3 of 8
(3,212 Views)
Tom wrote in news:3F8A2BE0.3CFC26A1@nOpam.com:
> Case1
>
> if N>5
> it does one thing
> case 2
>
> if N<-5
> it does something else
> case 3
>
> if -5<5
> it does a third thing.

In at least LabVIEW 6.0 and later:


Case1 selector value = "6.."
Case2 selector value = "..-6"
Case3 selector value = "-5..5"
(dont input the ")
This is for integer values.

If you have floats then you will need to use a rounding function and
convert the number to integer afterwards. To get exactly the case values
with floats will need some work. If this is the case and you have a problem
with that then post again.

--
Rolf
0 Kudos
Message 4 of 8
(3,212 Views)
Out of many solutions....
Hope this quick example helps!
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 Kudos
Message 5 of 8
(3,212 Views)
Don`t forget, that if N=5 or N=-5, you will have a fourth case.....

>= and <= are required somewhere I would guess.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 6 of 8
(3,212 Views)
shoneill wrote in message news:<5065000000050000007B2C0100-1042324653000@exchange.ni.com>...
> Don`t forget, that if N=5 or N=-5, you will have a fourth case.....
>
> >= and <= are required somewhere I would guess.
>
> Shane.

Thanks you that seems to work but how do I input the integer values
into the case from the front panel? ie how do I make a control such
that I can vary
the limit 5 to 6 or 7 or whatever from the front panel?

Thanks

Tom
0 Kudos
Message 7 of 8
(3,212 Views)
In this case, you need to use three cases with boolean logic.

In this example, the function checking if the supplied number is in range can be right-clicked to change whether the limiting values themselves are considered valid or not (Including maximal or minimal / excluding maximal or minimal).

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 8 of 8
(3,212 Views)