maniootek Posted March 31, 2021 Share Posted March 31, 2021 (edited) #include "Array.au3" ArrayInArrayTest() Func ArrayInArrayTest() Local $Array[][] = [ [1,2,3], [4,5,6], [7,8,9] ] Local $ArrayInArray[] = [ $Array ] _ArrayDisplay($ArrayInArray, "ArrayInArray") _ArrayDisplay($ArrayInArray[0], "ArrayInArray[0]") ($ArrayInArray[0])[0][0] += 1 ;<-- syntax error EndFunc I am trying to increase value in 2D array cell but this array is in another array and I got syntax error. I have no idea how to fix this. Any idea? I could not find any information about this in this article: https://www.autoitscript.com/wiki/Arrays Edit: After wiriting this post I found a solution. Not sure if this is right but it works: #include "Array.au3" ArrayInArrayTest() Func ArrayInArrayTest() Local $Array[][] = [ [1,2,3], [4,5,6], [7,8,9] ] Local $ArrayInArray[] = [ $Array ] _ArrayDisplay($ArrayInArray, "ArrayInArray") _ArrayDisplay($ArrayInArray[0], "ArrayInArray[0]") $aTempArray = $ArrayInArray[0] $aTempArray[0][0] += 1 $ArrayInArray[0] = $aTempArray _ArrayDisplay($ArrayInArray[0], "ArrayInArray[0]") EndFunc Edited March 31, 2021 by maniootek Link to comment Share on other sites More sharing options...
Nine Posted March 31, 2021 Share Posted March 31, 2021 But usually it is better to create a function to help modifying the inner array : #include <Constants.au3> #include "Array.au3" ArrayInArrayTest() Func ArrayInArrayTest() Local $Array[][] = [ [1,2,3], [4,5,6], [7,8,9] ] Local $ArrayInArray[] = [ $Array ] _ArrayDisplay($ArrayInArray, "ArrayInArray") _ArrayDisplay($ArrayInArray[0], "ArrayInArray[0]") ModifyArray ($ArrayInArray[0], 0, 0, 1) _ArrayDisplay($ArrayInArray[0], "ArrayInArray[0]") EndFunc Func ModifyArray(ByRef $aArray, $x, $y, $v) $aArray[$x][$y] += $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...
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