Showing results for 
Search instead for 
Did you mean: 

Get array Subset with variable length setting

Go to solution

Hi all,


I just hit a bit of a headscratcher with the Array Subset node. The help says that the default values are: index = 0 and length = rest.

As far as I understand, if you right-click a terminal and create constant, the constant is initialized with the default value as value. So if I do this for length, I get a numeric constant with 0, but when I run this, the function returns an empty array.

Array Subset.png

So in the VI, I get [4, 5, 6][7, 8, 9] for the top function and an empty array for the second. My question is: Why?

Is there a value, that I can wire to length, that would cause it to spit out the rest? I see this in LV 2018 and 2019.


Thanks in advance for any insight into this!

Remember Cunningham's Law
0 Kudos
Message 1 of 5

You're confusing default value for the function with default value for the datatype.


The default value for the function is "rest."  The default value will be used if the input isn't wired. 


The default value for a numeric is 0.  By creating the constant, you're overriding the function's default value with whatever you wire.  You're using the default value of a numeric to tell it you want a length of 0.


What's the output of an array of 0 rows?  It's an empty array.

Message 2 of 5

Hi Natas,


thanks for the quick response. You make a very good point for the output of the function. I want 0 rows, I get 0 rows so I should be happy. So the real question would be: What numeric value can I wire to the function to get the default (rest) behavior? I don't want to wire array size to it and I fully expected 0 or -1 to be some sort of exceptions, that let the node know to take the rest. I also don't want to wire 2147482647 to it.

I do know what the default value is. But I just realized that the behavior is very different between nodes and subVIs.

If you right-click an input of a node with a default value of -1 (e.g. length of the delete from array function) and create a constant you get a constant with value 0 instead of -1. The behavior will change from the default behavior.

If you do the same for a subVI with an input of default value -1, you will get a -1 and the behavior will stay unchanged until the constant's value is changed.

Remember Cunningham's Law
0 Kudos
Message 3 of 5
Accepted by topic author PeterFoerster

The point is you wouldn't wire a value if you want "the rest".


If you really must wire something, then you will need to determine what that desired length actually is and wire that up.  If you wire up a value too large, it will work, so the array size will always give you the rest.

Message 4 of 5

I guess so...

To clarify: The functionality I was after was to have the array subset in a subVI and to have that subVI have the same default functionality as the array subset. I'll have my default value for the subVI set to something high enough, then.


I was mainly thrown by the difference in constant creation between nodes and subVIs and just assumed that 0 was a special case that meant "rest".


Thanks for all the help!

Remember Cunningham's Law
0 Kudos
Message 5 of 5