Why is My Boolean Value Property Node a Variant?

Updated Aug 18, 2023

Reported In

Software

  • LabVIEW Base
  • LabVIEW Full

Issue Details

I have a Boolean Control. When I create a Value or Value (Signaling) Property Node, it appears as a variant type. Why is this?

Solution

This is because you are trying to create a Property Node from a Boolean control that has latching mechanical action. You cannot read or write Boolean values that are set with a latching mechanical action because race conditions can occur. When a Boolean is set to a latching mechanical action, it means that after you change the value of the Boolean, it will change back to the default once the VI reads its value. Therefore, depending on when the value of the Boolean is read by the VI or by the property node, you may miss a change in the value.

Try changing the mechanical action of your Boolean control to switching. This will allow you to use both the Value and Value (Signaling) Property Nodes, which you will notice will now be of type Boolean instead of Variant as shown below:
Boolean property node
A Boolean with a switching mechanical action will not revert back to default value when pressed only once.
 

Additional Information

This behavior can also occur when trying to assign a Boolean value to a front-panel control being referenced as type Control, even if it is typecast to Boolean using the To More Specific Class function. This is because the control reference isn't being cast to a Boolean with a specific mechanical action.

Because the property node cannot tell if the control is being typed as a latching or switching Boolean, the property node is unsure of the exact set of properties to provide/exact kind of data to expect, and defaults to coercing the data passed to it to Variant.