LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Inputs and outputs of subvi's

This should be a relatively simple question. Is there a way to add inputs/outputs to a subvi that has already been created. It seems that if you go in and remove an input from a subvi there is no way of getting it back. For example: lets say i have a subvi that calculates the average of a group of numbers. So the input when the vi is initially created is a group of numbers. Now i want to use that same subvi to...find the mode of a different set of numbers. This requires an additional input. Is there a way of adding one without remaking the subvi??? Thanks.
0 Kudos
Message 1 of 6
(3,510 Views)
The right wat would be to turn your "group of numbers" into an 1D array of numbers and make the subVI input an array.

Now it will accept array inputs of any lenght. 🙂
0 Kudos
Message 2 of 6
(3,504 Views)
Ok assume the groups of numbers is a 1d array. But lets say, for the sake of argument, that i have two 1d arrays (array1 and array2) but have a subvi built to take only one input. I want to modify it, rather than starting over, to have a second input wire for array2. dont have time right now, but ill try to make an example later.
0 Kudos
Message 3 of 6
(3,500 Views)
Simple. Right click on the connector pane and select Add Terminal or select patterns and change to the one you want.
0 Kudos
Message 4 of 6
(3,488 Views)
Typically you should not change the number of connectors constantly, especially if that same subVI is already used in legacy applications.

If all 1D arrays have equal lenght, make it in to a 2D array and adjust the input accordingly. If the array lengths in a call can be different between inputs during the same call, make it an array where each element is a cluster containing an 1D array.
Alternatively, if there is a small upper limit of the number of input arrays, make a subVI with that number of inputs, then detect inside the subVI which one's are wired (e.g. check for "empty array" or similar).

To add an input to a subVI, create an additional control on its front panel, then show connectors in the icon pane, add a connector, and assign it to the new control.
In the calling VI, the VI is now greyed out because the connector pane no longer matches. right-click on it and do a "relink to subVI" to fix this.
0 Kudos
Message 5 of 6
(3,486 Views)
thanks, that's what i need to know.
0 Kudos
Message 6 of 6
(3,473 Views)