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: 

Issue creating subvi

Hi 

 

In my code I have some arrays and local variables of array.

When i highlight the section of code to make it a vi, those Arrays and local variables are thrown out of the subvi as terminals.

 

How can I keep them inside?

 

 

Thanks

0 Kudos
Message 1 of 3
(2,155 Views)

Use data flow (ie wires) instead of locals.


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
Message 2 of 3
(2,152 Views)

A little more detail. Local variables are not temporary storage locations. They are essentially duplicate terminals of a front panel control or indicator.  You cannot place a local variable linked to a control on the main VI into a subVI.

 

So, when you try to make a subVI from a segment of code which includes local variables, the LabVIEW development system creates new controls for the subVI and wires them in place of the local variables.

 

As crossrulz suggested, you should use wires rather than locals. With a very few, very limited exceptions local variables are not needed and not recommended in good LV code.

 

Lynn

0 Kudos
Message 3 of 3
(2,131 Views)