jorgepr13 Posted August 10, 2012 Posted August 10, 2012 (edited) Is there is a way to do this $arr[2][2] = [[1, 2], [3, 4]] but something like this? $arr[2][2] $arr[0][2]=[1,2] $arr[1][2]=[3,4] because declaring it like this may take a lot of space $arr[2][2] $arr[0][0]=1 $arr[0][1]=2 $arr[1][0]=3 $arr[1][1]=4 in the case that you don't want to have all the declarations in the same place that it may look messy and may confuse not knowing in what dimension you are Edited August 10, 2012 by jorgepr13
water Posted August 10, 2012 Posted August 10, 2012 No, you can't do it the way you described above. But if you want to fill the array with ascending numbers (1,2,3,4,5...) you can do it in a loop. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
jdelaney Posted August 10, 2012 Posted August 10, 2012 (edited) You can always do array in arrays, kind of array^2, rather than 2d array #include <Array.au3> Dim $aArray1[2] = [1,2] Dim $aArray2[2] = [3,4] Dim $aHouser[2] = [$aArray1,$aArray2] For $i = 0 To UBound ( $aHouser ) - 1 $currentArray = $aHouser[$i] _ArrayDisplay ( $currentArray ) Next This has the advantage of only needing to know the 1 level of dimensions, as well Edited August 10, 2012 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.
jorgepr13 Posted August 10, 2012 Author Posted August 10, 2012 the ascending/descending numbers are just for example (sorry if I post it in the wrong place, I found other post with the same title here)
water Posted August 10, 2012 Posted August 10, 2012 Be aware that the Array-in-Array-solution isn't recommended for performance reasons as you can read here at the end of the page. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
jorgepr13 Posted August 10, 2012 Author Posted August 10, 2012 (edited) You can always do array in arrays, kind of array^2, rather than 2d array #include <Array.au3> Dim $aArray1[2] = [1,2] Dim $aArray2[2] = [3,4] Dim $aHouser[2] = [$aArray1,$aArray2] For $i = 0 To UBound ( $aHouser ) - 1 $currentArray = $aHouser[$i] _ArrayDisplay ( $currentArray ) Next This has the advantage of only needing to know the 1 level of dimensions, as well will it work for differentiated dimensions? $arr[4][2] $arr[0][2]=[1,2] $arr[1][2]=[3,4] $arr[2][2]=[1,4] $arr[3][2]=[5,10] Edited August 10, 2012 by jorgepr13
jdelaney Posted August 10, 2012 Posted August 10, 2012 (edited) do whatever you want, but syntax must look like: #include <Array.au3> Dim $aArray1[2] = [1,2] Dim $aArray2[2] = [3,4] Dim $aArray3[2] = ["a","b"] Dim $aArray4[3] = [3,4,5] Dim $aArray5[2] = [9,10] Dim $aHouser[5] = [$aArray1,$aArray2,$aArray3,$aArray4,$aArray5] For $i = 0 To UBound ( $aHouser ) - 1 $currentArray = $aHouser[$i] _ArrayDisplay ( $currentArray ) Next edit: for your specific question, i'm thinking no Edited August 10, 2012 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.
AdmiralAlkex Posted August 10, 2012 Posted August 10, 2012 (edited) You can use the line continuation character ("_") to split long lines, example: #include <Array.au3> Local $arr[2][2] = [[1, 2], _ [3, 4]] _ArrayDisplay($arr) Edited August 10, 2012 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
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