2013-10-30 76 views
-1

顯然,Ubound不能這樣做,因爲您必須在其中指定尺寸以顯示大小。 是的,我知道,AutoIt不是最好的,當你需要處理複雜的數據或大型程序與模塊AutoIt中多維數組的大小

糟糕,我一定很累,然後錯誤地問,我的意思是,確定維數。 當您從另一個地方接收數組並且它是動態生成的時,您甚至無法循環任何維度,因爲您不知道它是否存在。只有嘗試並捕捉錯誤呢?

回答

2

從幫助文件:

UBound (Array [, Dimension]) 
Array The array variable which is being queried. 
Dimension [optional] Which dimension of a multi-dimensioned array to report the size of. Default is 1, which is the first dimension. If this parameter is 0, the number of subscripts in the array is returned. 

考慮到上述情況:

Local $myArray[10][20] ;element 0,0 to 9,19 

For $i = 1 To UBound($myArray, 0) 
    ConsoleWrite("Dimension: " & $i & " :" & UBound($myArray, $i) & @LF) 
Next 
0

是啊,我知道,那AutoIt的是不是最好的,當你有複雜的數據進行工作或帶模塊的大程序

錯,但我們留在話題上;)

讓我們用二維數組作爲例子。

爲了得到行數,使用

$iRowCount = UBOUND($array) 

要得到列數,使用

$iColCount = UBOUND($array, 2) 

需要總規模?

$iTotal = UBOUND($array) * UBOUND($array, 2) 

編輯:任何更大的? Loopit

​​