Returns the size of array dimensions or the number of keys in a map.
UBound ( Variable [, Dimension = 1] )
Remember that for arrays the value returned is one greater than the index of the last element in the dimension as the count starts at [0].
Global/Local, ReDim, IsArray, IsMap
#include <Array.au3>; Required for _ArrayDisplay.
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
Local $aArray[10][20]
Local $iRows= UBound ($aArray,$UBOUND_ROWS); Total number of rows. In this example it will be 10.
Local $iCols= UBound ($aArray,$UBOUND_COLUMNS); Total number of columns. In this example it will be 20.
Local $iDimension= UBound ($aArray,$UBOUND_DIMENSIONS); The dimension of the array e.g. 1/2/3 dimensional.
MsgBox ($MB_SYSTEMMODAL,"","The array is a "&$iDimension&" dimensional array with "&_
$iRows&" row(s) & "&$iCols&" column(s).")
; Fill the array with data.
For $i= 0To $iRows- 1
For $j= 0To $iCols- 1
$aArray[$i][$j]= "Row: "&$i&" - Col: "&$j
Next
Next
_ArrayDisplay ($aArray)
EndFunc ;==>Example
#include <AutoItConstants.au3>
_Example()
Func _Example()
ConsoleWrite ("> $aTest_1_Empty_Array"&@CRLF )
Local $aTest_1_Empty_Array[]
ConsoleWrite (UBound ($aTest_1_Empty_Array,$UBOUND_DIMENSIONS)&@CRLF )
ConsoleWrite (UBound ($aTest_1_Empty_Array,$UBOUND_ROWS)&@CRLF )
ConsoleWrite (UBound ($aTest_1_Empty_Array,$UBOUND_COLUMNS)&@CRLF )
ConsoleWrite ("> $aTest_2_Empty_1D"&@CRLF )
Local $aTest_2_Empty_1D[0]
ConsoleWrite (UBound ($aTest_2_Empty_1D,$UBOUND_DIMENSIONS)&@CRLF )
ConsoleWrite (UBound ($aTest_2_Empty_1D,$UBOUND_ROWS)&@CRLF )
ConsoleWrite (UBound ($aTest_2_Empty_1D,$UBOUND_COLUMNS)&@CRLF )
ConsoleWrite ("> $aTest_3_Empty_2D"&@CRLF )
Local $aTest_3_Empty_2D[0][5]
ConsoleWrite (UBound ($aTest_3_Empty_2D,$UBOUND_DIMENSIONS)&@CRLF )
ConsoleWrite (UBound ($aTest_3_Empty_2D,$UBOUND_ROWS)&@CRLF )
ConsoleWrite (UBound ($aTest_3_Empty_2D,$UBOUND_COLUMNS)&@CRLF )
ConsoleWrite ("> $aTest_4_1D"&@CRLF )
Local $aTest_4_1D[]= [0,1,2]
ConsoleWrite (UBound ($aTest_4_1D,$UBOUND_DIMENSIONS)&@CRLF )
ConsoleWrite (UBound ($aTest_4_1D,$UBOUND_ROWS)&@CRLF )
ConsoleWrite (UBound ($aTest_4_1D,$UBOUND_COLUMNS)&@CRLF )
ConsoleWrite ("> $aTest_5_2D"&@CRLF )
Local $aTest_5_2D[][]= _; [[0, 1, 2], [3, 4, 5]]
[_
[0,1,2],_
[3,4,5]_
]
ConsoleWrite (UBound ($aTest_5_2D,$UBOUND_DIMENSIONS)&@CRLF )
ConsoleWrite (UBound ($aTest_5_2D,$UBOUND_ROWS)&@CRLF )
ConsoleWrite (UBound ($aTest_5_2D,$UBOUND_COLUMNS)&@CRLF )
ConsoleWrite ("> $aTest_6_2D"&@CRLF )
Local $aTest_6_2D[][]= _; [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 1, 2]]
[_
[0,1,2],_
[3,4,5],_
[6,7,8],_
[0,1,2]_
]
ConsoleWrite (UBound ($aTest_6_2D,$UBOUND_DIMENSIONS)&@CRLF )
ConsoleWrite (UBound ($aTest_6_2D,$UBOUND_ROWS)&@CRLF )
ConsoleWrite (UBound ($aTest_6_2D,$UBOUND_COLUMNS)&@CRLF )
EndFunc ;==>_Example