03-23-2020 10:29 AM
Hello, can you help me?
In this simple VI the indicator *(type *) &x 2 of function type cast is not corresponding at input data cluster.
When I run VI the outut is 2.
Thanks a lot.
Michele
Solved! Go to Solution.
03-23-2020 10:37 AM
When nothing is found in the Search array the output is -1. I guess -1 translates to Enum 2.
So, depending on how you want to differentiate between No button pressed and '0' pressed you need to change some things.
So, assuming you want to show the selected button as Enum and no button pressed = 0, then you can do like this:
/Y
03-23-2020 10:38 AM
So when you don't click any buttons, the True value isn't found.
The returned value is "-1".
When you click the buttons, I guess you get the results you expect?
The problem is because when you take -1 and pass it to the U16 conversion, you get the maximum value (65535).
This then coerces to the largest value in the enum (which is the closest), which is 2.
03-23-2020 10:45 AM
Seems like you should just use a Radio Buttons instead. It will do all of the work for you.
03-23-2020 10:47 AM
Have you did any probing to see what the problem is? Did you notice that your Search Array gives an output of -1 when all values are FALSE? Did you notice that this gets changed to 65535 when you convert to an unsigned integer? It is unclear what you are trying to do. Do you need to handle cases where two of the controls are TRUE? Or all three are TRUE?
03-23-2020 04:47 PM
This method of coerce, coerces to the closest value.
-1 -> 0
100 -> 2
mcduff
03-23-2020 09:25 PM
@mcduff wrote:
This method of coerce, coerces to the closest value.
-1 -> 0
100 -> 2
mcduff
Take care with this, if you keep the to U16 then the -1 becomes ~65k and so is now closer to 2 than 0 (so it's the same behaviour as the current VI).
Maybe if the OP tells us what they're wanting to do we could suggest a simpler/more robust method?
03-31-2020 05:08 AM
Your solution is perfect for me.
Thanks a lot.