mexykanu Posted May 9, 2014 Share Posted May 9, 2014 (edited) Hello, I have been searching for a solution with no success so i would like to ask for your help. I am trying to add certain rows from one 2d array to another. I cannot get anything to work. dim $array1[0][0] $tabledata[4][4] = [ data1 ] [ EMPTY ] [ EMPTY ] [ EMPTY ] [ data1 ] [ data2 ] [ data3 ] [ data4 ] [ EMPTY ] [ data2 ] [ data3 ] [ data4 ] [ EMPTY ] [ EMPTY ] [ EMPTY ] [ EMPTY ] The following columns of row 3 from $tabledata should be copied into $array1: $tabledata[3][1] $tabledata[3][2] $tabledata[3][3] so that $array1 would have the following data: $array1[0][3] = [ data2 ][ data3 ][ data4 ] I have tried the following with no success: $array1[ubound($array1)-1][0] = $tabledata[3][1] _ArrayAdd($array1,$tabledata[3][1]) _ArrayAdd($array1[0][0],$tabledata[3][1]) It's also ok if i could get to copy all of row 3 of $tabledata into $array1, but that has not worked either. Could you please give me some help? Thank you. Edited May 9, 2014 by mexykanu Link to comment Share on other sites More sharing options...
mexykanu Posted May 9, 2014 Author Share Posted May 9, 2014 (edited) Problem solved. The problem with what i was doing here: $array1[ubound($array1)-1][0] = $tabledata[3][1] was Ubound-1 . Since the array was declared at size zero, autoit was trying to write at value -1 The correct way to do it was: dim $array1[0][2] $array1[ubound($array1)][0] = $tabledata[3][1] $array1[ubound($array1)][1] = $tabledata[3][2] $array1[ubound($array1)][2] = $tabledata[3][3] If i would use it in a loop, i would need to increase $array1's row count each time before writing into it. I would use for $i=1 to 100 ReDim $array1[UBound($array1)+1][2] $array1[Ubound($array1)][0] = $tabledata[3][1] $array1[Ubound($array1)][1] = $tabledata[3][2] $array1[Ubound($array1)][2] = $tabledata[3][3] next Thank you. Edited May 9, 2014 by mexykanu 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