AutoIt从数组中获取子数组

简单的代码片段,我们希望在另一个变量中存储数组元素(又是另一个数组):
Global $arr[1][2] = [ [1, 2] ]
Global $sub = $arr[0]
我们得到了
Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
Global $sub = $arr[0]
Global $sub = ^ ERROR
如果我们写
Global $arr[1][2] = [ [1, 2] ]
Global $sub[2] = $arr[0]
我们得到了
Missing subscript dimensions in "Dim" statement.:
Global $sub[2] = $arr[0]
Global $sub[2] = ^ ERROR
这么简单的任务,但我找不到如何做到这一点的方式。不知道。请帮忙。     
已邀请:
您正在创建具有2个维度的多维数组,而不是数组内部的数组。两者的区别如下: 多维数组:
Local $arr[1][2] = [ [1, 2] ]
Local $sub = $arr[0][0] ; value = 1
数组内部的数组:
Local $firstArray[2] = [1, 2]
Local $arr[1] = [ $firstArray ]
;Local $sub = $arr[0][0] ; This does not work

Local $sub = $arr[0]
$sub = $sub[0] ; value = 1
在AutoIt的大多数情况下,您更喜欢多维数组。另一个数组中的数组会创建原始数组的副本,因此您会丢失一些性能,并且对副本的修改不会影响原始数组。 最后,更喜欢使用Local关键字来定义变量而不是Global关键字。如果使用Local关键字声明变量,则可以避免污染全局命名空间。     

要回复问题请先登录注册