LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LVOOP Parent private data returned when child instance created from constant

Solved!
Go to solution

I have created one Parent class, and one Child class.  For each of these classes, I have created a member VI that is a constructor, whose purpose will be to initialize some constants for each class, and return the class instance.  I also have a member accessor VI for each class that returns the private data of the class (in this case a single string for each class).

 

The Parent class's private data "String" is set to"Parent text" as the default value.

The Child class's private data "Child String" is set to"Child Text" as the default value.

 

The Parent class constructor works just fine.  For testing purposes, I return the text from directly unbundling in the constructor VI, and as returned from the accessor VI. The Parent constructor starts from a class constant.

 

However, in the case of the Child class constructor, if I start from a class constant, directly unbundling the private data (using an Unbundle By Name function, and choosing "Child String" as the element), I get the Parent's private data!

If I use the Child class's member VI to retrieve the text, I get the Child's private data.

If I change the constructor to start from a class Control instead of a class Constant, I get the Child's private data.

 

This only occurs  before the Child class has existed as a Control/Indicator. i.e. If I unbundle the private data after the class  is returned by any member VI, I get the correct Child private data.  So obviously something changes once the class "data" has been a control at some point.

 

I am using Labview 8.6.1, Windows XP

 

I have attached a small project that illustrates the problem I am encountering, without actually doing any initialization, just reading.

 

Is this the intended behaviour?  Why does it matter if I start with a class constant instead of a class control?  When you drag from the Project window to the Block diagram, you always get a constant.

 

0 Kudos
Message 1 of 3
(3,401 Views)
Solution
Accepted by topic author pauldavey

Although I was able to replicate your issue in LabVIEW 8.6.1, it appeared to run correctly in 2009.  I could not find a CAR ID but at this point can only assume that the behavior was not intended but is fixed in 2009.

 

Let me know if you need me to find any further details.

Alex Person
NI-RIO Product Support Engineer
National Instruments
Message 2 of 3
(3,287 Views)

Thanks Alex

 

**** 

 

More discussions on LVOOP Constants here 

Certified LabVIEW Architect * LabVIEW Champion
0 Kudos
Message 3 of 3
(3,269 Views)