03-10-2010 05:32 PM
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
Solved! Go to Solution.
03-10-2010 06:08 PM
03-10-2010 08:03 PM
^ 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.
03-10-2010 08:46 PM
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.
03-10-2010 09:33 PM
Hi blawson,
I like your approach. I think it is very clean.
Yik
03-10-2010 09:36 PM
You are right, Ravens. My example was a bit coarse.
Yik