ArraySize()
Syntax
Result = ArraySize(Array() [, Dimension])Description
Returns the size of the array, as specified with Dim or ReDim.
Parameters
Array() The array to get the size from. Dimension (optional) For multidimensional arrays, this parameter can be specified to get a specific dimension size. The first dimension starts from 1.
Return value
Returns the size of the array dimension. If the array isn't yet declared (for example after FreeArray() or if its allocation has failed), it will return -1.
Remarks
As specified with Dim, the number of elements is equal to the size + 1. For example: Dim a(2) contains 3 elements from a(0) to a(2) for a size of 2.
Does not work with static arrays declared in Structures. Use SizeOf instead.
Example
Dim MyArray.l(10) Debug ArraySize(MyArray()) ; will print '10' Dim MultiArray.l(10, 20, 30) Debug ArraySize(MultiArray(), 2) ; will print '20' Dim MultiArray2.l(2,2,2) For n = 0 To ArraySize(MultiArray2(),2) MultiArray2(0,n,0) = n+1 Next n Debug MultiArray2(0,0,0) ; will print '1' Debug MultiArray2(0,1,0) ; will print '2' Debug MultiArray2(0,2,0) ; will print '3' Debug ArraySize(MultiArray2(),2) ; will print '2'
Example
Dim Test.q(99999999999999999) If ArraySize(Test()) <> -1 Test(12345) = 123 ; everything fine Else Debug "Array 'Test()' couldn't be initialized." EndIf
Example
Structure MyStructure ArrayStatic.l[3] ; Static array, only in structures Array ArrayDynamic.l(4) ; Dynamic array EndStructure Debug SizeOf(MyStructure\ArrayStatic) ; Display 12 Debug SizeOf(MyStructure\ArrayDynamic) ; Display 8 Ex.MyStructure Debug ArraySize(Ex\ArrayDynamic()); Display 4
See Also
ListSize(), MapSize()
Supported OS
All