new to Analytica 5.0
Returns the number of elements in index «I».
IndexLength is closely related to the Size function, but differs in that
IndexLength(I) gives the size of the index
Size(a) gives the size of the value
a. For a simple, non-dynamic index, these are the same, but they are usually different in the case where
a is a multi-dimensional self-indexed array, or where the size of a dynamic index is requested from within a dynamic loop.
IndexLength(I) is equivalent to
Size(IndexValue(I)), and to
Video: Why the IndexLength function is probably better than alternatives (4 minutes)
Index The_Date := Sequence(20-Jan-2009, 19-Jan-2017) Do IndexLength(The_Date) → 2922
Consider the case where variable
A is a self-indexed array:
Index Digit := 0..9 Variable A := [0, 10, 20, 30] + Digit Size(A) → 40 IndexLength(A) → 4
Index Time := 2017..2025 Dynamic(Size(Time)) → Array(Time, [1, 1, 1, 1, 1, 1, 1, 1, 1]) Dynamic(IndexLength(Time)) → Array(Time, [9, 9, 9, 9, 9, 9, 9, 9, 9])
Function IndexLength(I : Index) := Size(I)
or use the more verbose expression
Size(IndexValue(I)) when you need the size of the index.