Arrays 自动嵌套数组
我试图在Autoit中访问嵌套数组中的值,但收到超出范围的错误消息。 这是我的代码:Arrays 自动嵌套数组,arrays,variable-assignment,autoit,Arrays,Variable Assignment,Autoit,我试图在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 ( $combin
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