Carlo84 Posted November 9, 2011 Posted November 9, 2011 Hi all, ok i just spend quite sometime reading in the forums about declaring multi dimentional arrays. (funny how over years you can still be clueless about simple things cause you never really needed them)Anyways i figured it out thanks to posts from 2004 :-pWhen declaring arrays this way the Rows are grouped together.#include <Array.au3> Dim $MyArray[2][5] = [['Row[0] Col[0]', 'Row[0] Col[1]', 'Row[0] Col[2]', 'Row[0] Col[3]', 'Row[0] Col[4]'], _ ['Row[1] Col[0]', 'Row[1] Col[1]', 'Row[1] Col[2]', 'Row[1] Col[3]', 'Row[1] Col[4]']] _ArrayDisplay($MyArray)Now my question is is there anyway of declaring an multiple dimentional array with the Cols grouped together? _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders
spudw2k Posted November 10, 2011 Posted November 10, 2011 (edited) Try not to think of them specifically as rows and columns. You could just as easily swap the initializers to organize your elements differently, It just depends on how You want to organize the data. #include "array.au3" Dim $arr1[3][2]=[["First Name","Last Name"],["Spud","W"],["D","jarlo"]] _ArrayDisplay($arr1) Dim $arr2[2][3]=[["First Name","Spud","D"],["Last Name","W","jarlo"]] _ArrayDisplay($arr2) Maybe I'm not understanding the result you are looking to achieve. edit: I once made a function to "transform" a two-dimension array by swapping (rebuilding) the dimensions, effectively converting say $arr[3][2] to $arr[2][3] while retaining it's elements, but it's not on this computer (where I'm posting from). I'll see if I can dig it up later if you think it may be of use to you. Edited November 10, 2011 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Carlo84 Posted November 10, 2011 Author Posted November 10, 2011 (edited) Maybe I'm not understanding the result you are looking to achieve.Not trying to achieve anything specific but learning a little something about array declaration :-) Yes i do realize that in fact they are not really cols and rows, and your right, to work with them youll have to let that idea go. I once made a function to "transform" a two-dimension array by swapping (rebuilding) the dimensions, effectively converting say $arr[3][2] to $arr[2][3] while retaining it's elements, but it's not on this computer (where I'm posting from). I'll see if I can dig it up later if you think it may be of use to you.No thanks i just needed to know if they could be declared in such a way, and you answered that :-) I might not like it but hey once ya get used to it it wont matter anymore. Thanks for your help. Edited November 10, 2011 by Djarlo _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders
spudw2k Posted November 10, 2011 Posted November 10, 2011 (edited) in case you change your mind...i found the "transform" (properly dubbed transpose) function. here it is unsolicited. edit: It is designed for Two-Dimensional Arrays edit: Added Function Description/Usage Header and error checking ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArrayTranspose ; Description ...: Transpose a two-dimensional array ; Syntax.........: _ArrayTranspose(ByRef $arr) ; Parameters ....: $arr - The array to Transpose ; Return values .: Success - $arr Transposed ; Failure - 0, sets @error to: ; |1 - $arr is no an array ; |2 - $arr is not a two-dimensional array ; Author ........: Spudw2k ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _ArrayTranspose(ByRef $arr) If Not IsArray($arr) Then Return SetError(1, 0, 0) If Not UBound($arr,0) = 2 Then Return SetError(2, 0, 0) Dim $arrTrans[UBound($arr,2)][UBound($arr,1)] For $x = 0 To UBound($arrTrans,2)-1 For $y = 0 To UBound($arrTrans)-1 $arrTrans[$y][$x]=$arr[$x][$y] Next Next Return $arrTrans EndFunc Usage Example: #include "array.au3" Dim $array[3][2]=[["First Name","Last Name"],["John","Smith"],["David","Copperfield"]] _ArrayDisplay($array) $array = _ArrayTranspose($array) _ArrayDisplay($array) Edited December 18, 2011 by spudw2k Carlo84 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Carlo84 Posted November 10, 2011 Author Posted November 10, 2011 thank you kindly sir :-) Ps; oops sorry posted in wrong forum, maybe a mod coul;d place it in correct forum or close it. _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders
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