Aktonius Posted February 18, 2012 Share Posted February 18, 2012 (edited) Redim deletes content of every row of 2D array once i redim it to have one more row, but if i access any content like $array[0][0] by console or just by assigning this value to some crap value just before redim then everything works fine. I dont know why i am posting it as i will probably get "we need code" etc but this is nearly impossible to reproduce because everything works fine in a simple script, the thing is i have thousands lines of code Still, what could possible be reason something like this happens? Here is something that would work ok in normal code, but for some reason not in mine. Func _ArrayAdd_Custom(ByRef $array, ByRef $add_array) Local $newsize = UBound($array) + 1 ReDim $array[$newsize][8] For $column = 0 To 7 $array[($newsize-1)][$column] = $add_array[$column] Next EndFunc ;==>_ArrayAdd_Custom Edited February 18, 2012 by Aktonius Link to comment Share on other sites More sharing options...
Valik Posted February 19, 2012 Share Posted February 19, 2012 Sounds like a possible copy-on-write issue. Without reliable reproducing code, though, it doesn't seem like something to worry much about. Link to comment Share on other sites More sharing options...
Aktonius Posted February 19, 2012 Author Share Posted February 19, 2012 (edited) To solve this i simply changed it to Func _ArrayAdd_Custom(ByRef $array, ByRef $add_array) Local $newsize = UBound($array) + 1 Local $crapvalue ;WAKE UP ARRAY?!!? - after this redim wont delete content $crapvalue = $array[0][0] ReDim $array[$newsize][8] For $column = 0 To 7 $array[($newsize-1)][$column] = $add_array[$column] Next EndFunc ;==>_ArrayAdd_Custom Really one of weirdest issues i had with autoit, maybe calling this from wm_copydata has any connections to the problem, but then again i also tried to _array_add from dummy control, still same... Maybe it gives clues to someone with same issue one day Edited February 19, 2012 by Aktonius Link to comment Share on other sites More sharing options...
water Posted February 19, 2012 Share Posted February 19, 2012 (edited) What version of AutoIt do you run? I ran the following test script and get an array with 3 rows and 8 columsn as a result: #include <array.au3> Global $a2D[2][8] = [["1-1", "1-2", "1-3", "1-4", "1-5", "1-6", "1-7", "1-8"],["2-1", "2-2", "2-3", "2-4", "2-5", "2-6", "2-7", "2-8"]] Global $a2Add[8] = ["3-1", "3-2", "3-3", "3-4", "3-5", "3-6", "3-7", "3-8"] _ArrayAdd_Custom($a2D, $a2Add) _ArrayDisplay($a2D) Func _ArrayAdd_Custom(ByRef $array, ByRef $add_array) Local $newsize = UBound($array) + 1 ReDim $array[$newsize][8] For $column = 0 To 7 $array[($newsize - 1)][$column] = $add_array[$column] Next EndFunc ;==>_ArrayAdd_Custom Edited February 19, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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