Champak Posted January 29, 2014 Share Posted January 29, 2014 Is this possible, or do I just have to redim the first array and write the second one in through a loop? Link to comment Share on other sites More sharing options...
jdelaney Posted January 29, 2014 Share Posted January 29, 2014 (edited) Yes, and yes (that's one way to go). Probably want lots of error handling to make sure their dims line up. Simple example #include <array.au3> Local $array1[2][2]=[[1,2],[3,4]] Local $array2[2][2]=[[5,6],[7,8]] For $i = 0 To UBound($array2)-1 ReDim $array1[UBound($array1)+1][UBound($array1,2)] For $j = 0 To UBound($array2,2)-1 $array1[UBound($array1)-1][$j] = $array2[$i][$j] Next Next _ArrayDisplay($array1) not sure why this would ever be a case, but why not: #include <array.au3> Local $array1[2][2]=[[1,2],[3,4]] Local $array2[2][3]=[[5,6,7],[8,9,0]] For $i = 0 To UBound($array2)-1 ReDim $array1[UBound($array1)+1][UBound($array1,2)] If UBound($array1,2)<UBound($array2,2) Then ReDim $array1[UBound($array1)][UBound($array2,2)] EndIf For $j = 0 To UBound($array2,2)-1 $array1[UBound($array1)-1][$j] = $array2[$i][$j] Next Next _ArrayDisplay($array1) Edited January 29, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Champak Posted January 29, 2014 Author Share Posted January 29, 2014 Your route is a little different from how I was going to do it. I was just going to redim it once and then loop through everything. Ill try both ways to see which is faster. Thanks. Link to comment Share on other sites More sharing options...
jdelaney Posted January 29, 2014 Share Posted January 29, 2014 (edited) Yes, one redim would be quicker (when tons of data to concat)...just easier (conceptually) to increase by one each time...example with only one redim: #include <array.au3> Local $array1[2][2]=[[1,2],[3,4]] Local $array2[4][2]=[[5,6],[7,8],[8,9],[0,1]] ReDim $array1[UBound($array1)+UBound($array2)][UBound($array1,2)] For $i = UBound($array1)-1 To UBound($array1)-UBound($array2) Step -1 For $j = 0 To UBound($array1,2)-1 $array1[$i][$j] = $array2[$i-UBound($array1)+UBound($array2)][$j] Next Next _ArrayDisplay($array1) Edited January 29, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now