01-16-2019 12:35 PM - edited 01-16-2019 12:37 PM
Why does a Boolean Control Value and Value (signaling) property node input and output a Variant instead of a Boolean?
Solved! Go to Solution.
01-16-2019 12:42 PM
Latch action
01-16-2019 12:46 PM
As Christian said, if your Boolean control is set to one of the Latch mechanical settings, the value property is a variant.
01-16-2019 12:48 PM
Thanks, I see that now.
I don't use a lot of locals or property nodes and never noticed this before
01-17-2019 04:47 AM
While I'm aware the mechanical action settings of a boolean lead to this, I feel like this is still weird behaviour.
Does anyone have a link to a discussion as to WHY it's neccessary at all to output a variant as opposed to a Boolean value? It seems like the datatype of the returned data is irrelevant in this regard.
01-17-2019 09:59 AM - edited 01-17-2019 10:01 AM
All right, I have to say it. Google is your friend. 😄
I googled: "labview why latching boolean is variant" - first hit.
01-17-2019 10:08 AM
01-17-2019 10:16 AM - edited 01-17-2019 10:17 AM
Older versions of LabVIEW will throw a runtime error if you insist on doing it, and it says so in the help. But in newer versions, that tidbit is deleted from the help. Does that mean it no longer throws an error?
01-17-2019 10:37 AM
"Why" questions are hard to answer unless we are in the room when the decision was made...
Could have to do with Latch Action terminals will change the state of the Boolean but a property node will not.
We also cannot use a local to write to a latch action Boolean.
That is all that comes to mind at the moment.
Ben
01-17-2019 12:05 PM
Well, latch booleans reset when read by the code but it probably would be unpredictable if reading in multiple places via property nodes would each reset it. Locals aren't even allowed, while value property nodes will give you a runtime error, so the variant can never have inspectable data. So yes, seeing a variant as boolean value property means (Bad, not a boolean, don't use)
Same for writing to secondary terminal (local, value property). What should happen if you write if the button has already been pressed but not yet read? Many other scenarios. Can of worms!
Of course you might argue that writing a signaling property is more similar to actually pressing a button, so read this discussion for some perspectives.