LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pass values to subVi by reference from main Vi

 

I have multiple subVIs that has a loops inside. The mainVi calls these subVis. I need to pass the parameters and even be able to stop the subVIs from the mainVI. Cannot launch the subVI front panel (which would run it in separate execution).

The only way I have found so far is to create a shared variable (single process) for stop and any parameter that needs to be passed from main VI to subVI. Then monitor the shared variable value in the subVI for change. Is there any pros/cons of using this approach and is there any other approach to achieve this behavior instead of using shared variable?

Can the variable be passed by reference and subVi can read the value? Or is  there any way to register the events, generate the event on main Vi  and when the mainVI generate the event, subVI receives that event and performs accordingly?

Attach is the zip file.

TIA.

*************************************************
CLD
*************************************************
0 Kudos
Message 1 of 3
(15,583 Views)

Hi lvrat,

 

A control reference can be passed between VIs, as shown by this example. Additionally, this example describes how to do custom user events, and how to queue them. As far as pros/cons, I recommend passing the control reference, as this will get you the best performance.

Cheers!

TJ G
Message 2 of 3
(15,543 Views)

for any other LV beginner, like me, that follows in these footsteps, reading the VI server reference must occur INSIDE the while loop. Hopefully, that'll save someone 2 hrs

Message 3 of 3
(11,999 Views)