LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to access a class self attributes?

Solved!
Go to solution

Let's say I am the class "Human", how can I read the values of my own attributes set by an external code to use them in my own methods?

Just like self in python

0 Kudos
Message 1 of 8
(404 Views)

What should I do if I want to use the value of the "number of fingers" attribute to perform the calculation required for, lets say, the "grab something" method?

0 Kudos
Message 2 of 8
(349 Views)

A class' attributes are accessed with a simple Unbundle by name in its methods.

External VI's need some access method, like get/set methods.

See "Human class" attached

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 8
(342 Views)

So in LabVIEW the class data is private. 
To read and write to the class data from outside one will need to create methods/vi's to accces the data. 

Within a class method you can use the unbundle/bundle by name to get access to the private data. 
In the class method, the class wire acts as cluster for data. 

0 Kudos
Message 4 of 8
(339 Views)

So the only way for the method "grab something" to access the attribute "number of fingers" is having the instance of the object "Human" wired as an input?

0 Kudos
Message 5 of 8
(327 Views)
Solution
Accepted by eloi.sanchez

@eloi.sanchez wrote:

So the only way for the method "grab something" to access the attribute "number of fingers" is having the instance of the object "Human" wired as an input?


Maybe?

If Grab is a method of Human, then yes, you need your class wire attached. If Grab is a free VI then it depends. It might need a Hand-reference or just the integer Number of fingers and so on.

What are you trying to achieve?

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 8
(321 Views)

yes, in this Grab example it is a Human method.

I was wondering if there was a way to access a class attribute without having to change the connector panel.

I am redoing someone else's work and am looking for a way to do it in the most elegant and least intrusive way.

0 Kudos
Message 7 of 8
(318 Views)

Are you talking about CLASS attributes of OBJECT attributes?

 

A CLASS is a definition of the data structures and methods in the IDE. An OBJECT is what you instantiate in code.

 

Accessing attributes of a CLASS in code is a very different thing to accessing attributes of an OBJECT (of that class) in code.

Message 8 of 8
(314 Views)