# Combining Arrays into Multi-Dimension

## Recommended Posts

I'm trying to get the hang of Multi-Dimension arrays but not having much luck

I have 3 Arrays which I'd like to combine into a single Multi-Dimension array, they all contain the same amount of elements if that makes a difference

Edited by AcidCorps

##### Share on other sites

I'm trying to get the hang of Multi-Dimension arrays but not having much luck

I have 3 Arrays which I'd like to combine into a single Multi-Dimension array, they all contain the same amount of elements if that makes a difference

```#Include <Array.au3>
Dim \$Array0[3], \$Array1[3], \$Array2[3]
;Value = array.element
;Array0
\$Array0[0] = "0.0"
\$Array0[1] = "0.1"
\$Array0[2] = "0.2"

;Array1
\$Array1[0] = "1.0"
\$Array1[1] = "1.1"
\$Array1[2] = "1.2"

;Array2
\$Array2[0] = "2.0"
\$Array2[1] = "2.1"
\$Array2[2] = "2.2"

Dim \$Combo [3][3]
For \$y = 0 to 2
\$Combo[0][\$y] = \$Array0[\$y]
Next
For \$y = 0 to 2
\$Combo[1][\$y] = \$Array1[\$y]
Next
For \$y = 0 to 2
\$Combo[2][\$y] = \$Array2[\$y]
Next
_ArrayDisplay(\$Combo, "Combined Arrays")```

Just one example.

Edited by Paulie

##### Share on other sites

I'm trying to get the hang of Multi-Dimension arrays but not having much luck

I have 3 Arrays which I'd like to combine into a single Multi-Dimension array, they all contain the same amount of elements if that makes a difference

Paulie's example works fine, and they don't have to be the same number of elements. You could just use Ubound() to find the longest one and use that for your new array's number of rows. Depending on how much logic you want to code into it, you could put together arrays with different numbers of dimensions too, because Ubound(\$avArray, 0) can be used to determine the number of subscripts (dimensions) and adjust the output accordingly.

If you're going to do a lot of this, it would be better to code a generic function to append the scripts together.

Edited by PsaltyDS

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

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...