Dim(a:Array, [d:Int]):Int
Get size of an array. Returns the number of elements in the d'th dimension of array a. d starts from 1, that is, for a two-dimensional array, you can pass 1 or 2 here.
The return value is the number of elements in the array's dimension. The highest possible index into the array is one less than the value returned.
For example,
Dim a(10) Print Dim(a) % returns 10 Print Dim(a,1) % also returns 10 For i:=0 To Dim(a)-1 Do ... % iterates
If any parameter is EMPTY, returns EMPTY.
Since 1.99.22, this function also works for builtin arrays such as Ship(). Note that builtin arrays often don't have a zero element (i.e. there is no Ship(0)). For iteration through ships, you would therefore use
For i:=1 To Dim(Ships) Do ...
Better, however, is to use ForEach.
Since: PCC2 1.99.12
See also: IsArray (Elementary Function), Dim (Elementary Command), Elementary Functions