Sub-Arrays


Subscript ranges are used to select a sub-array from an array by giving the starting and ending subscripts of the subarray in each dimension.

Subscript ranges may be combined with array subscripts and other subscript ranges to define the bounds of any sub-array.

dim y(4)
y(1:3) = 5

0

5

5

5

0


Subscript ranges are written (Start : End). This sets the bounds of a sub-array to a range from index Start to End. Start may not be greater than End, but Start may equal End.


dim y(4)
y(2:*) = 5

0

0

5

5

5


An Asterisk (*) is used to select all elements of a given dimension.

(Start : *) indicates a sub-array from element Start to the last element in the dimension.



In a multidimensional array, when a dimension is specified by a single value or a range reduces to a single value, that dimension becomes degenerate and collapses. In the example above, the first two dimensions are fixed (3,7,*). They will never vary so they become irrelevant. The array returned a() is a one dimensional array with 11 elements.


dim y(4)

y(1:3) = 5

redim y(4,1)

y(*,1) = y(*,0)

0

0

5

5

5

5

5

5

0

0


Sub-Arrays combined with Array Operations gives Mintoris Basic power formerly reserved for high end mathematics/statistical analysis languages.



Arrays and Subscripts







Become a Patron