LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exchanging Data from main vi to sub vi with call by reference - how?

Solved!
Go to solution

Hello,

 

as mentioned before in another thread (http://forums.ni.com/ni/board/message?board.id=170&thread.id=390355), I have a main vi with a stop button and a sub vi, which needs some seconds to finish.

 

During the execution of the sub vi, I want the stop button of the main vi to take effect instantly, which means the sub vi should stop right away.

 

I know that I can exchange data between vis somehow with a call by reference, but all the examples I found, transfer data from the sub vi to the main vi, but I want it the other way round.

Since I have never used the call by reference, I have no idea how I can do that.

Attached you find, what I have done so far. 

 

I would be very happy if you help me and show me how to use the call by reference correctly.

 

Johannes

 

LabVIEW 7.1 (I used to program with C and Labview 6)

Win XP

 

Johannes

Message Edited by johanneshoer on 02-27-2009 09:37 AM
Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
Download All
0 Kudos
Message 1 of 5
(3,325 Views)

Hi Johannesh,

 

I'm not sure whether you've any specific reason to use call by reference, but if not, I'd recommend using other method to exchange data between main and sub vi.

In this case, I believe global variable should be sufficient enough.

You may refer to http://zone.ni.com/devzone/cda/tut/p/id/7531 on how to use Global Variable.

 

Regards, Kate

0 Kudos
Message 2 of 5
(3,313 Views)

Kate,

thank you very much for the quick response.

 

Yes, there is a specific reason to use call by reference. If the sub vi is executed, it takes some time to finish and the button in the main vi would take effect not before the sub vi is finished.

 

But since the button in the main vi is kind of a emergency stop button, it should stop the sub vi instantly. I cannot do this with global variables. right?

 

Johannes

Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 3 of 5
(3,305 Views)
Solution
Accepted by topic author johanneshoer

I solved it!

A reference and a property node does it.

See attachment

 

Johannes

Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
Download All
Message 4 of 5
(3,279 Views)

KateB wrote:

Hi Johannesh,

 

I'm not sure whether you've any specific reason to use call by reference, but if not, I'd recommend using other method to exchange data between main and sub vi.

In this case, I believe global variable should be sufficient enough.

You may refer to http://zone.ni.com/devzone/cda/tut/p/id/7531 on how to use Global Variable.

 

Regards, Kate


 

 

Hi Kate,

 

Global variables can introduce Race Conditions that can be hard to locate and fix.

 

A better alternative is to use an Action Engine since they are not subject to race conditions when properly developed.

 

I wrote a Nugget on Action Engine ( that can be found here) to help others avoid the headaches that arise from Global variable use*.

 

Just trying to help,

 

Ben

 

* Please note that I did NOT call globals evil (this time). Smiley Wink

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 5
(3,272 Views)