Page 1 of 1

Retrieving number of elements in an array

Posted: Fri Mar 07, 2014 8:35 pm
by tasdvl9
Hi Everyone,

I've been looking all over for a simple way to retrieve the number of elements in an array.
Is there a function which returns this?

For instance, say I have an array called myArray and within it has 32 elements.
How do I acquire this info?

Thanks!

Re: Retrieving number of elements in an array

Posted: Fri Mar 07, 2014 8:42 pm
by FourthWorld
You can get the keys of an array, which is a return-delimited list, from which you can get the number of lines.

For arrays with consistent integer keys, you may also be able to use the extents function, but note it's limitations in the Dictionary before relying on it, as its only works with certain types of key ranges.

Re: Retrieving number of elements in an array

Posted: Sat Mar 08, 2014 10:34 am
by Thierry
You can get the keys of an array, which is a return-delimited list, from which you can get the number of lines.
This solution is great for one dimensional arrays.

Thierry

Re: Retrieving number of elements in an array

Posted: Sat Mar 08, 2014 7:17 pm
by dunbarx
Richard, Thierry,

This was similar to a recent thread, where someone wanted to get "the elements of the second nested level of an array". Or the fifth.

Might this warrant a feature request;

get arrayElements(arrayName,depth)

Craig