LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

boolean (reference) and boolean are incompatible

Solved!
Go to solution

hello,

 

I have a sub VI that receives a reference to a boolean input.

I need this reference to monitor the state of the boolean input throughout the operation of the sub VI.

 

The input is a stop button. The VI is supposed to frequently check the state of the stop button and in case of it being true, stops its actions.

 

I set the class of the refnum to be boolean, like so (your language may differ):

defined class.png

 

In order to get the value from the reference, I right click on it -> create -> property node -> value.

This is the way I was taught to get properties from things.

It creates one of those smaller property node blocks.

 

This value however is not usable. When I try to connect it to a logical OR, LV complains about the types being incompatible.

Aparently a boolean (reference) cannot be compared to a boolean.

That doesn't make any sense to me.

Could somebody please explain it?

Why is there a difference?

 

There was another option available:

right click on the reference -> create -> property for Boolean(strict) class -> value.

This creates a regular property node block, with a usable boolean value.

This value is preset to show the correct properties.

Do I still have to wire the reference input of this property node?

Or is this "connected" to the reference the same way as the other "wireless" node?

 

Please see image below that shows both described ways to retrieve the value:

 

two ways to retrieve the value.png

 

thank you for your help

0 Kudos
Message 1 of 16
(8,772 Views)
Solution
Accepted by topic author max_

Hi max,

 

your property node type "A" is not made for a boolean control, it seems to represent a reference as value.

Edit: you created a property node for your reference control. The "value" of that reference control will be of type "reference" - no matter what the reference should point to! You need to connect by wire a generic property node from the functions palette to your reference control!

 

When you want to use "generic" property nodes: right-click your boolean control and "create->reference". For that reference you can create a control to obtain a suitable reference control!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 16
(8,760 Views)

Thanks Gerd,

 

I assumed that the A node property would implicitely dereference the pointer, so to speak. But it doesn't.

 

While figuring this out, I noticed that there's an entry in the right click menu of the reference input: "add datatype", that can be ticked or not.

Adding the datatype adds a red star to the reference input in the front panel.

It also turns the type of the property node from variant into boolean.

 

So I can specify a class, add a datatype and also can create a typedefinition.

I come from other programming languages where these 3 things all seem to be one thing: the type of a variable.

Why are there those 3 seemingly redundant ways in LV to specify the type, or at least something that I think is something similar to what I know as a type of a variable.

This is very confusing.

0 Kudos
Message 3 of 16
(8,744 Views)

Hi max,

 

Adding the datatype adds a red star to the reference input in the front panel.

Adding the datatype make the reference "strict" (as is noted in the context help window!). You can have a reference to an unspecified boolean control. But you can make it a special reference to a very specific boolean control by setting the datatype!

 

Background: There can be differences between boolean controls. The can have different appearance in the FP, but they also can have different  behaviour. Most prominent case of "different behaviour" is the switching mode of a boolean control…

 

So in summary: you can have more generic references and more specific ones. You need to choose the correct ones depending on their purpose!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 16
(8,737 Views)

@max_ wrote:

Thanks Gerd,

 

I assumed that the A node property would implicitely dereference the pointer, so to speak. But it doesn't.

 

While figuring this out, I noticed that there's an entry in the right click menu of the reference input: "add datatype", that can be ticked or not.

Adding the datatype adds a red star to the reference input in the front panel.

It also turns the type of the property node from variant into boolean.

 

So I can specify a class, add a datatype and also can create a typedefinition.

I come from other programming languages where these 3 things all seem to be one thing: the type of a variable.

Why are there those 3 seemingly redundant ways in LV to specify the type, or at least something that I think is something similar to what I know as a type of a variable.

This is very confusing.


It'll come to you, but they're not the same. First of all, the boolean control isn't a variable, it's a front panel object which you in this case access through its reference (whether or not that is a good design/solution is another matter). The wire is the variable.
The typedef is simply a saved "struct" so you can easily use the same thing everywhere and propagate changes you want to do. This is especially useful for clusters, and to some degree Strict typedefs for coherent look.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 16
(8,728 Views)

And this is what I don't quite understand.

 

There already is a notion of more or less "strictness" by choosing a class. Depending on where the class is in the inheritance chain, the more or less specific are the available options.

So why aren't there more specialised classes subclassing Boolean to choose from?

0 Kudos
Message 6 of 16
(8,721 Views)

Hi max,

 

see it this way: "strict" is related to a very specific control on your FP. When you change properties of that control (like the switching mode of a boolean button) the control changes and also the strict reference need to change. Therefor you need to set it to strict afterwards…

 

Try this:

Create a generic "element" reference on your FP. Then drop any other control of your FP on that reference control!

What happens? By dropping that very specific control on your reference it becomes a strict reference of this very type of control…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 16
(8,714 Views)

Thanks again Gerd for trying to help me understand this.

I understand what it does, but not why. In a few other programming languages one specifies the strictness of a type by exactly that: the type, there's no need for a "hey you, type over there! yes, you - be strict!".

 

But I came to terms with it. I settled on "this makes no sense to me, but I have to deal with it the way it is".

Thank you for your effort.

0 Kudos
Message 8 of 16
(8,707 Views)

Hi max,

 

again: when you select a boolean element from the right-click menu of the reference (as you have shown in your first message) you select only a generic boolean control, thus the reference is non-strict. By pointing to a specific boolean control you make the reference strict as it now keeps track of the very specific properties of that boolean control.

 

A "boolean control" is more than just a bit of information! Maybe that's the difference to your "few other languages"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 16
(8,703 Views)

@max_ wrote:

I understand what it does, but not why. In a few other programming languages one specifies the strictness of a type by exactly that: the type, there's no need for a "hey you, type over there! yes, you - be strict!".


The type has no strictness, it's a boolean. The front panel control has strictness, just like you have some 213 properties for each and every visual control in .net. (rough estimation) 😉

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 16
(8,685 Views)