Array in Array

Recommended Posts

Is it possible to implement in AutoIt array, each element of which represents a different array of arbitrary length? For example,

Array[n] = [Array, Array[j], Array[k], ...]

i<>j<>k

Any ideas.

Share on other sites

Yes:

```Dim \$a[3] = [1, 2, 3]
Dim \$b[3] = [4, 5, 6]
Dim \$c[3] = [7, 8, 9]

Dim \$avArray[3] = [\$a, \$b, \$c]oÝ÷ ØzË"­Êh²Èébæ®¶­sdf÷"b33c¶ÒFò ¢Æö6Âb33c¶F×Òb33c¶d'&²b33c¶Ð ¢b4'&b33c¶F×FVà¢f÷"b33c¶¢ÒFòT&÷VæBb33c¶F×Ó¢6öç6öÆUw&FRb33c¶F×²b33c¶¥Òf×²D"¢æW@¢6öç6öÆUw&FRÄb¢VæD`¤æW```

Share on other sites

```Dim \$a[3] = [1, 2, 3]
Dim \$b[3] = [4, 5, 6]
Dim \$c[3] = [7, 8, 9]

Dim \$avArray[3] = [\$a, \$b, \$c]

For \$i = 0 To UBound(\$avArray) - 1
Local \$aTmp = \$avArray[\$i]

If IsArray(\$aTmp) Then
For \$j = 0 To UBound(\$aTmp) - 1
ConsoleWrite(\$aTmp[\$j] & @TAB)
Next
ConsoleWrite(@LF)
EndIf
Next```

Only one correction I made to his script otherwise give him all the credit for it

For \$i = 0 To UBound(\$avArray) - 1

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share on other sites

Thanks, but how to get in your sample, for example, only the number 3?

CODE
ConsoleWrite(\$aTmp[0][2]) - does not work.
What you are doing there is trying to get a value from a 2d array. To get a value from the "array in the array" you must do as Authenticity showed. By the way what are you really trying to do? Storing arrays in arrays are very rarely used and there is often another "better" solution.

Share on other sites

What you are doing there is trying to get a value from a 2d array. To get a value from the "array in the array" you must do as Authenticity showed. By the way what are you really trying to do? Storing arrays in arrays are very rarely used and there is often another "better" solution.

I hurried to the reply, I have decided this.

Thank you.

Another thing that comes to mind is an array of pointers.

`\$Array[n] = [\$hWnd1, \$hWnd2, ...]`
Edited by Yashied

Share on other sites

I hurried to the reply, I have decided this.

Thank you.

Another thing that comes to mind is an array of pointers.

`\$Array[n] = [\$hWnd1, \$hWnd2, ...]`
Do you know you are good at confusing people?

That look like a normal 1d array to me.

Share on other sites

Do you know you are good at confusing people?

That look like a normal 1d array to me.

I do not who did not enter into confusion. I'm trying to get an array, each element of which must contain a package of data (strings, pointers, integer data, etc.). The pointer is just a way to get to the package. I do not want to create a multi-dimensional arrays for this purpose.

Remark.

I just want to know which option is preferable: a multidimensional array, or dynamic memory.

Edited by Yashied

Share on other sites

I do not who did not enter into confusion. I'm trying to get an array, each element of which must contain a package of data (strings, pointers, integer data, etc.). The pointer is just a way to get to the package. I do not want to create a multi-dimensional arrays for this purpose.

Remark.

I just want to know which option is preferable: a multidimensional array, or dynamic memory.

Within AutoIt, a 2D array is clearly preferable. Just define the array in your comments for reference. Example:
```; 2D array containing 12 "packages":
; [0][0] = 1st string name
; [0][1] = 1st window handle
; [0][2] = 1st integer result
; [0][3] = 1st pointer to \$tagPOINT struct
; ...
; [11][0] thru [11][3] = last "package"
Global \$avArray[12][4]```

The third window handle would be: \$avArray[2][1]

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share on other sites

Within AutoIt, a 2D array is clearly preferable. Just define the array in your comments for reference. Example:

```; 2D array containing 12 "packages":
; [0][0] = 1st string name
; [0][1] = 1st window handle
; [0][2] = 1st integer result
; [0][3] = 1st pointer to \$tagPOINT struct
; ...
; [11][0] thru [11][3] = last "package"
Global \$avArray[12][4]```

The third window handle would be: \$avArray[2][1]

Thanks.

Create an account

Register a new account