![]() ZBasic System Library
297
ZBasic Microcontrollers
Type
Function returning an integral value
Invocation
Span(array) or
Span(array, dimension)
Parameter
Method
Type
Description
array
ByRef
any array
The array about which the dimension information is desired.
dimension
ByVal
int16
The dimension of interest. See the description for more
details.
Discussion
This function returns the number of elements in a dimension of the specified array. There are two forms.
The first requires only the array to be specified. In this case, the number of elements of the first
dimension of the array is returned. The second form specifies a dimension number (which must be a
constant value), the valid range of which is 1 to the number of dimensions of the array. The array may be
located in RAM, Program Memory or Persistent Memory.
Note that the use of this function instead of hard-coding values makes your code easier to maintain
because it automatically adapts if the definition of an array changes.
Example
Dim ba(1 to 20) as Byte
Dim ma(3 to 5, -6 to 7) as Byte
Dim i as Integer
i = Span(ba)
' the result is 20
i = Span(ma)
' the result is 3
i = Span(ma, 1)
' the result is 3
i = Span(ma, 2)
' the result is 14
Compatibility
This function is not available in BasicX compatibility mode.
See Also
|