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!
Retrieving number of elements in an array
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Retrieving number of elements in an array
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.
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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Retrieving number of elements in an array
This solution is great for one dimensional arrays.You can get the keys of an array, which is a return-delimited list, from which you can get the number of lines.
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: Retrieving number of elements in an array
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
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