From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to change constants in Sub-VIs from the top VI?

How is it possible to alter the constants in sub-VI block diagrams, from a top VI front panel?

Is it necessary to create & wire up terminals between the top VI's front panel and the sub-VIs in question, or are there other ways? What are the trade-offs?

Thanks
0 Kudos
Message 1 of 5
(2,606 Views)
Hey M00se,
 
Just like in other programming languages constants are only changable in the code is self  not programmatically.  If you need to change values in a subvi from a top vi the best way to do this is to either use a global variable or to pass the value into the subvi through connector.  Just passing the value in through a connector is the cleanest and most efficient way.  A variable will work but you have to be careful not to create race conditions.

Brian
Message 2 of 5
(2,598 Views)
You can use GLOBALS to do this. If you aren't familiar with GLOBALS,
just perform a search in FIND EXAMPLES.

TJW

>How is it possible to alter the constants in sub-VI block diagrams, from a top VI front panel?
>
>Is it necessary to create & wire up terminals between the top VI's
>front panel and the sub-VIs in question, or are there other ways? What
>are the trade-offs?
>
>Thanks

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

Hi m00se,

     Do you want to alter a value while the Sub-VI is running?  If not, then Brian has described the best way to supply the value.  If so, then Globals are certainly easy, but consider passing a value by its "reference".  In the caller, create a reference to a control, pass it to the Sub-VI, and use a VI-server property-node to obtain the Value property.  Unlike the Global, passing by reference leaves an audit-trail" for debugging the logic. Smiley Wink 

Cheers.

When they give imbeciles handicap-parking, I won't have so far to walk!
0 Kudos
Message 4 of 5
(2,588 Views)
other then using global variable,, there is one more method to do the same..
 
in that,,,,,, the value of the variable is passed from main vi to subvi,,,
 
even note that,, this is the efficient way from which can make recursive call too,,,
 
best regards
manisha
Download All
0 Kudos
Message 5 of 5
(2,571 Views)