frank10 Posted January 18, 2021 Share Posted January 18, 2021 (edited) I create a 2D Array with another Array inside it. I can read single rows of the inner array [encapsulating the outer Array with (...) ], but I can't change them, how to do this? local $aHeader = [ 0, 4 ] global $aData = [[1, $aHeader]] MsgBox(0,'', ($aData[0][1])[1] ) ; read ok --> 4 ($aData[0][1])[0] = 2 ; --> ERR, how to modify the arr inside the $aData 2d Arr? EDIT: Also, I can't insert the array inside the 2d Arr without using an intermediate var... $aData[0][1] = $aHeader ; ok $aData[0][1] = [1,2] ; ERR Edited January 18, 2021 by frank10 Link to comment Share on other sites More sharing options...
Nine Posted January 18, 2021 Share Posted January 18, 2021 You cannot set it like that , you need to use an array to perform the modification : #include <Array.au3> local $aHeader = [ 0, 4 ] Global $aData = [[1, $aHeader]] MsgBox(0,'', ($aData[0][1])[1] ) ; read ok --> 4 Local $aTmp = $aData[0][1] $aTmp[1] = 2 $aData[0][1] = $aTmp _ArrayDisplay($aData[0][1]) SetArr($aData[0][1], 0, 3) _ArrayDisplay($aData[0][1]) Func SetArr (ByRef $aArr, $i, $v) $aArr[$i] = $v EndFunc “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
pixelsearch Posted January 18, 2021 Share Posted January 18, 2021 Another way to do it : local $aHeader = [ 0, 4 ] global $aData = [[1, $aHeader]] MsgBox(0,'', ($aData[0][1])[1] ) ; read ok --> 4 ; ($aData[0][1])[0] = 2 ; --> ERR, how to modify the arr inside the $aData 2d Arr? _ASA($aData[0][1], 1, 2) MsgBox(0,'', ($aData[0][1])[1] ) ; read ok --> 2 ; --------- Assign to Sub-Array (ASA) --------- Func _ASA(ByRef $array, $iIndex, $Value) $array[$iIndex] = $Value ; Assign the new value. EndFunc ;==>_ASA Link to comment Share on other sites More sharing options...
Nine Posted January 18, 2021 Share Posted January 18, 2021 @pixelsearch What is the difference with my second example ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
pixelsearch Posted January 18, 2021 Share Posted January 18, 2021 I just saw your 1st example, not the 2nd lol Link to comment Share on other sites More sharing options...
frank10 Posted January 18, 2021 Author Share Posted January 18, 2021 Ok, thank you. Using temp var to modify it. 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