11-12-2022 01:58 PM
Thank you very, Mr. Altenbach !!! Great information. I learned something new. This is why I like this forum!
11-13-2022 10:59 AM
@altenbach wrote:
@GRCK5000 wrote:How are you able to insert booleans (G, Y, R) in enum? How did you do that?
A radiobutton container (boolean palette) is similar to a cluster, but it can only contain booleans. Any style and number of booleans!!!!
Only exactly one (or also none of so configured) can be TRUE at any given time, As soon as another one turns true, all others turn false automatically. This is very useful and often dramatically simplifies your code.
In your case, you would place a radiobutton control from the palette, then drop your three LEDs in it. Now you can remove the two booleans that were originally in there. You can change the cluster order if needed. Of course you can make it a control (typical) or an indicator (as in this case).
The type is an enum with values for all element names in cluster order. The current value of the enum is the label of the element that is currently true, so make sure all elements have unique and clear labels, even if they don't show on the front panel.
( Also have a look at my description here and vote for it if you like. 😄 )
Very nice.
In the linked description you wrote "Of course a VI with an empty radio button control should probably be broken." I would have worded it 'Of course a VI with an empty radio button control would have to be broken.' I just can't imagine what value an empty radio buttons cluster would have (it would be like a enum with no items).
11-13-2022 11:54 AM - edited 11-13-2022 11:56 AM
@paul_cardinale wrote:
In the linked description you wrote "Of course a VI with an empty radio button control should probably be broken." I would have worded it 'Of course a VI with an empty radio button control would have to be broken.' I just can't imagine what value an empty radio buttons cluster would have (it would be like a enum with no items).
Well, that idea is way over 10 years old!
Maybe I should take that sentence back. An Enum placed freshly from the palette has no items and does not break the VI, so maybe an empty radiobutton control should not even break the VI. We just need to define how it should behave. 😄
Similar the "AND array elements" of an empty boolean array is TRUE, even if that's not necessarily obvious to some people..
11-14-2022 02:43 PM
Similar the "AND array elements" of an empty boolean array is TRUE, even if that's not necessarily obvious to some people..
I have used this in my code. I hope your not suggesting we change that 😁
@altenbach wrote:
@paul_cardinale wrote:
In the linked description you wrote "Of course a VI with an empty radio button control should probably be broken." I would have worded it 'Of course a VI with an empty radio button control would have to be broken.' I just can't imagine what value an empty radio buttons cluster would have (it would be like a enum with no items).. An Enum placed freshly from the palette has no items and does not break the VI, so maybe an empty radiobutton control should not even break the VI. We just need to define how it should behave. 😄
Why does an empty cluster container break the VI if empty enums do not? 😕
11-14-2022 03:06 PM
@Frozen wrote:
Similar the "AND array elements" of an empty boolean array is TRUE, even if that's not necessarily obvious to some people..
I have used this in my code. I hope your not suggesting we change that 😁
No, the current behavior is correct, just not necessarily obvious to some.
Here's explicit code to do the same as "and array elements". If the array is empty, the number of iterations is zero and the TRUE is returned unchanged. 😄
11-14-2022 05:12 PM
@Frozen wrote:
Similar the "AND array elements" of an empty boolean array is TRUE, even if that's not necessarily obvious to some people..
I have used this in my code. I hope your not suggesting we change that 😁
@altenbach wrote:
@paul_cardinale wrote:
In the linked description you wrote "Of course a VI with an empty radio button control should probably be broken." I would have worded it 'Of course a VI with an empty radio button control would have to be broken.' I just can't imagine what value an empty radio buttons cluster would have (it would be like a enum with no items).. An Enum placed freshly from the palette has no items and does not break the VI, so maybe an empty radiobutton control should not even break the VI. We just need to define how it should behave. 😄
Why does an empty cluster container break the VI if empty enums do not? 😕
There's no such thing as an empty enum. When you place a new one, it has one item (which is undeletable) that has an empty string as its name.
11-15-2022 03:23 AM
@Frozen wrote:
Similar the "AND array elements" of an empty boolean array is TRUE, even if that's not necessarily obvious to some people..
I have used this in my code. I hope your not suggesting we change that 😁
There have been quite lengthy and heated discussions about this in the long ago past. And the mathematically educated consensus was that this IS the way it should be. There is a good reason for it, even if it is not very intuitive to the casual layperson. 😀
11-15-2022 08:31 AM - edited 11-15-2022 08:39 AM
Similar the "AND array elements" of an empty boolean array is TRUE, even if that's not necessarily obvious to some people..
Summary of my understanding of the rationale is tied to set theory:
In each case, the result of operating on an empty set is to produce the IDENTITY value for that operator.
This understanding carries over into the numerical operators for finding the sum or product of an array. In the case of an empty array, you once again get the identity value for the operator.
The results for AND and PRODUCT are often unexpected. AND in particular shows up "in the wild" with some regularity in code, PRODUCT seems to be needed less commonly. Here's a simple workaround for the array AND situation with an empty array:
-Kevin P
11-15-2022 09:41 AM
Since the original discussion about traffic lights has run its course and we are now completely offtopic, there is an additional issue I have with AND/OR array elements:
While most boolean operations work in integers (bitwise!), these two array operations don't. Is there a fundamental explanation or is it just a glaring omission?
I'll have to look in the ideas exchange if this has been mentioned. It would be relatively easy to do a vim that accepts any type of integer arrays with any number of dimensions.