Jump to content

Recommended Posts

Posted

Ok say i have 3 arrays

$array1

$array2

$array3

How could i add $array2 to the end of array $array1 and then add $array3 to the end of $array1 (which would at this point would contain $array2)

Thanks

Posted

#include<array.au3>

Dim $array1[4] = [0,1,2,3]
Dim $array2[4] = [4,5,6,7]
Dim $array3[4] = [8,9,10,11]

$array4 = ArrayMerge($array1, $array2)
$array4 = ArrayMerge($array4, $array3)

_ArrayDisplay($array4)

;$amArray1: Array to add to
;$amArray2: Array to merge into previous
Func ArrayMerge($amArray1, $amArray2)
    Local $tempArray = $amArray1
    Local $amElements = Ubound($tempArray) + Ubound($amArray2)
    Redim $tempArray[$amElements]
    Local $amCount = 0
    For $X = Ubound($amArray1) to $amElements - 1
        $tempArray[$X] = $amArray2[$amCount]
        $amCount += 1
    Next
    Return $tempArray
EndFunc

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...