LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Default array value to detect wiring

I have two VIs: one main vi, and one subVI. The main vi may wire an array into the subVI, or it may not. If it does, I want to use that array in the subVI; if it does not, I want to build an array with some set of default values within the subVI and use that.

As far as I can tell, I cannot (programmatically) detect within the the subVI whether or not the array has been wired in. So what I'm trying to do is have the array constant be empty, and then detect the size of the array when the subVI starts. If it's empty, I know I must create an array; if it's size is 1 or more, I know that an array has been wired in.

Is this reliable? If I set the front panel array object to be empty, will it always be empty every time the subVI s
tarts, or will LabVIEW leave the previous set of values in it? (I seem to remember noticing previously that sometimes front panel objects would retain the value from the previous run, and sometimes would start off fresh).

Is there any other way to accomplish what I'm trying to do, rather than using default values? Or, is there something like NaN for an array? (Not for an array element, but for the array itself).
0 Kudos
Message 1 of 3
(2,885 Views)
If the array in the subvi is connected to a terminal, then
when that sub vi is called from the other vi, this is the observed behavior:

if the terminal is wired , the array takes the input values from the calling vi
if the terminal is left unwired, the array uses its default value. If the default value is empty (dimension zero), the it will have array size of zero


(Note if the array is not connected to a terminal, then it will always take the values set whenever the subvi is called, and each call uses the previoulsy set values at the end of execution of the subvi)
0 Kudos
Message 2 of 3
(2,885 Views)
If you're not calling the subVI multiple times in parallel, you'll be okay. If you're going to going to run in parallel, it might be safest to make the subVI reentrant so that each instance can run with distinct and separate data storage.
0 Kudos
Message 3 of 3
(2,885 Views)