# UDim

From Br Wiki

UDIM(<array name> [,<dimension>])

The **UDim(A$,X)** internal function returns the number of rows in the array if X=1. Returns the number of columns in the array if X=2. Returns the current size of dimensions 3, 4, 5, 6 or 7 when X is 3, 4, 5, 6 or 7. If the optional parameter X is omitted, UDIM returns the size of the first dimension.

#### Comments and Examples

00010 DIM A(15,20) 00020 PRINT UDIM(A), UDIM(A,1), UDIM(A,2) 00030 FOR I = 1 TO UDIM(A) 00040 FOR J = 1 TO UDIM(A,2) 00050 LET A(I,J) = I + J 00060 NEXT I 00070 NEXT J

The three numbers printed in line 20 will be 15, 15 and 20. Notice that by using UDIM in lines 30 and 40 this program can be changed to use a different sized two-dimensional array; the only programming change would be to change the dimensions in line 10 (or the array could be redimensioned using the MAT statement).

The following example increases the size of array arr$ by one element:

00010 mat arr$(udim(arr$)+1)

#### Related Functions

Other functions that operate on arrays are: