298 of 318
ZBasic System Library 288 ZX Microcontroller Family UBound Type Function returning Integer Invocation UBound(array) or UBound(array, dimension) Parameter Method Type Description array ByRef any array The array about which the bound information is desired. dimension ByVal int16 The dimension of interest. See the discussion for more details. Discussion This function returns the upper bound of the specified array. There are two forms. The first requires only the array to be specified. In this case, the upper bound of the first dimension of the array is returned. The second form specifies a dimension number, 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. In contrast to LBound(), a parameter that is an array cannot be passed to UBound()since the return value of UBound() is computed at compile-time and many different sized arrays may be passed as a parameter. Note that the use of this function instead of hard-coding values makes your code easier to maintain. Example Dim ba(1 to 20) as Byte Dim ma(3 to 5, -6 to 7) as Byte Dim i as Integer i = UBound(ba) ' the result is 20 i = UBound(ma) ' the result is 5 i = UBound(ma, 1) ' the result is 5 i = UBound(ma, 2) ' the result is 7 Compatibility This function is not available in BasicX compatibility mode. See Also LBound