Scripting > UNICOM Intelligence Function Library > Categorical functions > UBound
 
UBound
Returns the largest available subscript for the indicated dimension of an array. By default, the upper bound is returned for the first dimension of the array.
Syntax
UBound(List [, Dimension])
Parameter
List
Type: Categorical
Array or Categorical value.
Dimension
Type: Long
Array dimension to use. The default is 1.
(return)
Type: Long
Upper bound of the list.
Remarks
This function returns the numeric index of the last item in (a particular dimension of) an array. If Dimension is greater than the number of dimensions in the array, the last dimension is used, and if Dimension is less than 1, the first dimension is used. A Categorical value is treated as a one-dimensional array.
This function is similar to the UBound function in Visual Basic.
Example
The following mrScriptBasic example defines a two-dimensional array that has 10 rows and an undefined number of columns and assigns a value to the third column in the fourth row. UBound is then used to return the upper bound values of the two dimensions.
Dim MyArray[10][], x, y

MyArray[3][2] = 28

x = UBound(MyArray, 1) ' Returns 9
y = UBound(MyArray, 2) ' Returns 2
See also
Categorical functions