LBOUND
Jump to navigation
Jump to search
The LBOUND function returns the smallest valid index (lower bound) of an array dimension.
Syntax
- result% = LBOUND(arrayName[, dimension%])
- result% = LBOUND(parentArray(index).subordinateNestedArray[, dimension%])
Description
- arrayName specifies the name of the array.
- dimension% specifies the dimension number, starting with 1 for the first dimension.
- If omitted, dimension% is assumed to be 1.
- If dimension% is less than 1 or is greater than the number of dimensions, a subscript out of range error occurs.
- LBOUND and UBOUND are used to determine the range of valid indexes of an array.
Notes on the second Syntax
QB64-PE v4.5.0 extends LBOUND support for arrays nested inside TYPE definitions. Besides the traditional use on ordinary arrays, LBOUND may now also be used on an individual nested array member, or on a parent array/variable containing such members.
Availability
-
all
-
all
-
yes
-
yes
-
yes
- Since arrays in TYPEs were implemented in QB64-PE v4.5.0, this statement was adapted to properly handle it (see Example 2).
Examples
- Example 1
- The classical use on ordinary arrays.
DIM myArray(5) AS INTEGER DIM myOtherArray(1 TO 2, 3 TO 4) AS INTEGER PRINT LBOUND(myArray) PRINT LBOUND(myOtherArray, 2) |
0 3 |
- Example 2
- The new usage on subordinary and nested arrays.
TYPE test a(1 to 50) AS LONG END TYPE DIM Parent(1) AS test PRINT LBOUND(Parent) PRINT LBOUND(Parent(0).a) |
0 1 |
See also