LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing value of variable from within subVi

Hello,

 

In my MainVI, I want to send a variable, say a Boolean, as an input to a SubVI. If the value of this boolean changes within the subVI, I want to reflect the changes instantly in the MainVi.

 

How can I achieve this? I know, global variable can be an option but I do not want to use it.

 

Thank you.

 

-H

0 Kudos
Message 1 of 6
(3,096 Views)

You can pass a reference of the control to the subVI.

Then you can use the 'Value' or 'Value (signaling)' (triggering a value change event) properties to get/set the value.

 

Hope this helps

 

0 Kudos
Message 2 of 6
(3,094 Views)
I prefer to keep subVIs decoupled from the user interface as much as possible. One thing I have done to achieve this is to define a general purpose UI queue that can pass updates data to the UI task so the user interface can be updated. The queue data can be simply the data itself or a cluster which provides so identifier for the data to be updated and the data itself. Using a generalized approach the data would be passed as a variant. Within the subVI it will post the data to the queue. If the queue doesn't exist the subVI will simply ignore the error and nothing will be posted to the queue. In this manner the application can determine if data updates should occur. For instance, we have a general connection object that encapsulates the different connection interfaces into a class. Applications then will support the various interfaces types (USB, serial, TCP, parallel, Bluetooth, etc.). The read and write methods use the generic queue to post data that is being written or read from the interface. This is handy for applications that will want to provide a monitor of communications to the user.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 6
(3,054 Views)

Try using a functional global (FG) instead.  With the FG, you can save the value into a shift register of the FG and get it later on.

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 4 of 6
(3,042 Views)

H P wrote:

Hello, In my MainVI, I want to send a variable...



What's a variable? 😉
0 Kudos
Message 5 of 6
(3,037 Views)
Is the sub-vi really that big/slow that it needs to change the variable itself? The common (the most common?) is to send a variable/thread into a sub-vi and then recieve the result as an output. In this case you can get the output and assign it to the indicator (which i assume you want).

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 6
(3,029 Views)