LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing values between different vi's

Solved!
Go to solution

Simple application. In main VI i click button for new window with subvi. In this subvi i can choose value from menu ring. When i click diffrent button on main VI i want to send what is choosen in subvi, to indicator in main VI. Why this doesnt work?

Download All
0 Kudos
Message 1 of 11
(5,856 Views)

Can you save your code for LV 2012 or earlier?

 

What I usually do with a popup is wait until the user presses an "ok" button and then close the SubVI. Make the value an output of the SubVI, and wire directly to the terminal on MainVI.

 

You can also send in a control reference and update via property node.

0 Kudos
Message 2 of 11
(5,841 Views)

In theory, your subVI is still running, so any calls to the subVI while it is running will be blocked.  You should use a Queue or User Event to send data to your subVI.  Look up Queued Message Handler for some good ideas.


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
0 Kudos
Message 3 of 11
(5,840 Views)

I attached version 12. Can you tell me how change it in app?

Download All
0 Kudos
Message 4 of 11
(5,824 Views)

I don't think you should be messing around with call by reference. Just set your SubVI to "open when run" and "close afterward if originally closed".

0 Kudos
Message 5 of 11
(5,816 Views)

I try to set "close afterward if originally closed", but this doesnt help. 😕

0 Kudos
Message 6 of 11
(5,812 Views)

In order to respond the changes to front panel values, the  SubVI launched using VI Server calls must be running in a loop and passing data to any other code that is running in parallel to it. The mechanism to handle passed data could be Notifiers, Queues, *gasp* functional globals, or *gasp* *gasp* global variables. Since you're concerned with only the last value, the recommendation here is a Notifier.

 

Create a Notifier and pass its refnum to the SubVI that you launch using VI Server calls. The launched SubVI can then write to the Notifier and the Main VI can read from the value from the Notifier.

 

Main.vi:

Main.png

Sub.vi:

Sub.png

Feel free. Contact me for anything more,
    Pang

You too can be LabVIEW Awesome!
0 Kudos
Message 7 of 11
(5,756 Views)

Here is a simple example to show how to use a sub VI to get a user input.

 

 

Download All
0 Kudos
Message 8 of 11
(5,751 Views)

... or you have an OK button in the popup and simply connect an output with the value. Or even simpler, you can use the Express VI Prompt user for input for the same effect.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 11
(5,710 Views)
Solution
Accepted by crisdragon

Hi,

there are many ways how to do that. Check out my modification of you initial example. It really depend if you need non-blocking or blocking dialog window.

 

BR,

Ondřej

CLA, CTA, CLED
Download All
0 Kudos
Message 10 of 11
(5,667 Views)