UDim: Difference between revisions
No edit summary |
|||
Line 6: | Line 6: | ||
====Comments and Examples==== | ====Comments and Examples==== | ||
00010 DIM A(15,20) | 00010 DIM A(15,20) | ||
00020 PRINT UDIM(A), UDIM(A,1), UDIM(A,2) | 00020 PRINT UDIM(A), UDIM(A,1), UDIM(A,2) | ||
Line 15: | Line 16: | ||
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 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==== | ====Related Functions==== | ||
Other functions that operate on arrays are [[AIdx]] | |||
Other functions that operate on arrays are: | |||
[[AIdx]] | |||
[DIdx]] | |||
[[Srch]] | |||
[[Sum]] | |||
Revision as of 09:11, 1 February 2012
UDim(array-name[,X])
The UDim 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:
[DIdx]]