05-01-2023 12:03 PM
Hello, I'm trying to build a case selector with several cases that takes a numeric input and if its value is within 90% of the reference, do case A, if it's within 70% of reference, do case B, etc. The reference changes every loop.
So for example, I my reference is 3.3, if I read 2.97 to 3.3, do case A, if I read 2.31 to 2.96, do case B, etc.
I've tried to connect numeric control to case structure, shown on picture, but it only seems to work for integers, if I change those values to decimal, I am getting error. Another issue with this method is that I can only hardcode these values by typing values in case selector, I cannot set it to variables. Same thing with enum cases, you can't set them to variables only to constants as far as I know.
Solved! Go to Solution.
05-01-2023 12:12 PM - edited 05-01-2023 12:13 PM
You're correct, when you wire a DBL to the case structure, it gets coerced into an integer, so it's generally not recommended. You could multiply by 100, so your first case would be "297..330", but that's kind of hacky and you might forget when you go to edit the code.
I would use multiple case structures, or select functions (if you just need a single value). You can use "in range and coerce" to check if a value is in a range.
05-01-2023 12:16 PM
@John32d wrote:
Hello, I'm trying to build a case selector with several cases that takes a numeric input and if its value is within 90% of the reference, do case A, if it's within 70% of reference, do case B, etc. The reference changes every loop.
So for example, I my reference is 3.3, if I read 2.97 to 3.3, do case A, if I read 2.31 to 2.96, do case B, etc.
I've tried to connect numeric control to case structure, shown on picture, but it only seems to work for integers, if I change those values to decimal, I am getting error. Another issue with this method is that I can only hardcode these values by typing values in case selector, I cannot set it to variables. Same thing with enum cases, you can't set them to variables only to constants as far as I know.
Enums are static and cannot be changed at run time.
For your case structure, make your reference the variable and have cases for various percentages, like below