LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass class as DVR to another VI, but change of class member does not seem to apply

I am writing an application where I am supplying a set of APIs to interact with my application. I ran my application as async via VI reference,  I make an API class, and I intended to write results from my application to this API class.   In order to pass the data into my API class, I sent a API class DVR into my application, and modifying the class member in it. However, it does not seem that class member value change as it suppose to if it were by reference ?  Where did I do wrong  ? 

0 Kudos
Message 1 of 6
(2,398 Views)

@marxious wrote: Where did I do wrong  ? 

Impossible to really say without code.  But my shot in the dark would be you forked the object wire instead of the DVR wire.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 6
(2,309 Views)

If you put an object (anything, including a class) in a DVR, (conceptually) a copy is put in the DVR.

 

So changing the object in the DVR won't change the original object. After you've put it in the DVR, you need to access the object from the DVR (in both 'threads').

 

(This is exactly what @crossrulz said, but from a different angle.)

Message 3 of 6
(2,280 Views)

wiebe@CARYA wrote:

(This is exactly what @crossrulz said, but from a different angle.)


I would say a more complete answer.

 

Spoiler
I was just hit with a new requirement that is causing a massive re-write of code I have been waiting a long time to integrate with and so I don't have much time to elaborate on most of my ideas at the moment.

GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 6
(2,265 Views)

Also, G# and GOOP is already classes with references. Similar to your idea, but correctly implemented, they use DVRs internally to reference a class' data.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
Message 5 of 6
(2,262 Views)

@Yamaeda wrote:

Also, G# and GOOP is already classes with references. Similar to your idea, but correctly implemented, they use DVRs internally to reference a class' data.

/Y


G# and GOOP do it differently, but it isn't wrong to put a normal object in a DVR to get a 'by reference' object. (Not sure if that is what you're saying). I'd avoid it, and try to use other means of distributing objects ((user) events, queue, channel wire). This better fits the 'by value\by wire' model.

 

Of course if you want everything by reference (the wrong way 🙄, but some people seem to really like it), you're way better of with G#\GOOP\OpenGDS.

0 Kudos
Message 6 of 6
(2,106 Views)