LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Not Not Not in Case Structure

Solved!
Go to solution

Want to get some suggestion on the best way to do this.  In theory, it will be the best if I can create a case structure with "not" condition.  What I mean is if the input to the case structure is 3, and I have a case that with condition such as not(1, 2, 4, 5), the case would execute. 

 

Another example

if x not equal to 1, 2, 4, 5, then

   do this

elseif x not equal to 6, 7, 8, 9, then

   do that

End

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 6
(2,916 Views)
Are you looking for something like this
Ron Deavers, CLD
Download All
Message 2 of 6
(2,903 Views)
Solution
Accepted by jyang72211

^ you can also just make an array with your constants in it and feed the array to the comparison, and that puts out a bool array.

 

another approach would be to wire the numeric directly to the case structure and type the numbers you want a case to represent.  Multiple numbers for one case are comma separated.  A range of numbers can be represented by ".."  e.g. 6,7,8,9 = 6..9   Similarly, ..0 is the range  -inf through 0, and 5.. is all values greater than or equal to 5.

 

cases.png 

-Barrett
CLD
Message 3 of 6
(2,875 Views)

jyang72211 wrote:

Want to get some suggestion on the best way to do this.  In theory, it will be the best if I can create a case structure with "not" condition.  What I mean is if the input to the case structure is 3, and I have a case that with condition such as not(1, 2, 4, 5), the case would execute. 

 

Another example

if x not equal to 1, 2, 4, 5, then

   do this

elseif x not equal to 6, 7, 8, 9, then

   do that

End

 

Yik


Your pseudocode kind of falls apart for the elseif comparison.  You don't need the second comparison.

 

Let's say your number happenn to be 1.

 

Since it IS equal, the first then case does not occur, so the elseif gets evaluated.  Since it is NOT equal to 6, 7, 8, or 9, then the second then case will occur.  The only way it gets to the elseif is it is NOT 1, 2, 4, or 5.  And all of those are always Not equal to 6,7,8,9

 

 

In summary

 

if 1, 2, 4, 5, case 2 occurs

if anything else, then case 1 occurs.

 

Much simpler evaluation.

 

 

 

 

0 Kudos
Message 4 of 6
(2,869 Views)

Hi blawson,

 

I like your approach.  I think it is very clean.

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 5 of 6
(2,859 Views)

You are right, Ravens.  My example was a bit coarse.

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 6 of 6
(2,858 Views)