1

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
4

2 に答える 2

0

問題は、$combinedを2次元配列として扱うことです。しかし、それは1次元配列です。(あなたの見返りに)。

$ one [$ combined[$i]]を試してください

于 2012-07-01T00:27:05.533 に答える
0
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
于 2012-07-02T11:31:29.540 に答える