>我正在尝试访问 Autoit 中嵌套数组中的值,但我收到超出范围的错误消息。这是我的代码:
Func ThisFunction()
local $one[6] = [1, 2, 3, 4, 5, 6]
local $two[6] = [7, 8, 9, 10, 11, 12]
local $combined[2] = [$one, $two]
For $i = 0 to UBound($combined)-1
$result = SomeFunction ( $combined[$i] )
If $result Then
return $combined[$i][0]
EndIf
Next
EndFunc
有没有办法从嵌套的$combined数组中访问/返回特定索引?
编辑:我找到了一个可行的解决方案,我不知道这是否是好的做法
For $i = 0 to UBound($combined)-1
$result = SomeFunction ( $combined[$i] )
If $result Then
local $temp = $combined[$i]
If IsArray($temp) Then
return $temp[0]
EndIf
EndIf
Next
您的问题是您将$combined视为二维数组。但它是一个一维数组。(在您的回报中)。
尝试$one[$combined[$i]]
For $i = 0 to UBound($combined)-1
$result = SomeFunction ( $combined[$i] )
If $result Then
local $temp = $combined[$i]
If IsArray($temp) Then
return $temp[0]
EndIf
EndIf
Next