LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

(LVOOP Question) How does one access another class's data within another class?

Solved!
Go to solution

Hello-

 

Ass the title suggests, how do I get access to another class's (or is it class'?) data from inside another (different) class?  I'll attach an image showing where my problem arises...

 

I was told this:

http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/setting_scope_classes/

Might contain some helful info, but I still can figure out how to unbundle DAQs class data inside the Parts class (as seen in pic attached).

 

I'm thinking there might be something simple I'm missing here when it comes to LVOOP or OOP in general...  if any of you are willing to enlighten me, it'd be very much appreciated!

 

Thanks!

-pat

0 Kudos
Message 1 of 4
(3,304 Views)
Solution
Accepted by topic author plyons.gks

The private data is always private, you can not ever set it public. The unbundle cluster function can only be used on the class wire when inside the class. If you need access to private data, you need to create accessors.

 

It's simple, just right click the class and select New, VI for Data Member Access. It'll prompt a dialog for you to fill out what data items you want to create, and if you want them available through property nodes (recommended). Once finished, this will generate the VIs. Afterward, you can use in any other VI. The nice thing about making them property nodes is that you can plop down a property node and wire the class to it, and all the accessor functions that are created will appear in the list.

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

Message 2 of 4
(3,300 Views)

Thanks for the reply!  kudos to you

 

"The private data is always private, you can not ever set it public."   - always as in always? Smiley LOL     there's no way to do it even if you set up the classes to be "friends" or antyhing?   

 

I'm made accessors before, but never used the property node option, either way, I think this is the solution to my problem at hand.

 

Thanks again

-Pat

0 Kudos
Message 3 of 4
(3,287 Views)

yes, always as in always. I am an avid believer that you never use the words "never" and "always". (pun intended). But in this case. It's always true. Anything set to private (or forced private by LabVIEW's standards) can not ever be accessed outside the class. Not by friends or inheritence.

 

Also, if my post answers your question, please mark it to help others that may have this issue in the future and to help current posters know the thread is answered.

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

Message 4 of 4
(3,282 Views)