blenkhn Posted December 9, 2005 Share Posted December 9, 2005 How does one lopp through a two dimension array if one doesn't know the length of the second array. Rows are easy but what about the columns. the columns can be any number from 1 to 10 Any Help is appreciated. Link to comment Share on other sites More sharing options...
randallc Posted December 9, 2005 Share Posted December 9, 2005 Hi, See help file ubound($ar_Array,2) gives the 2nd dimension size (cf my Array2.au3 function from linkin signature) ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Hoxpital Posted April 22, 2007 Share Posted April 22, 2007 Also just wanted to point out that in AutoIt, the first entry in an array is the [0] entry (or the [0][0] entry in a 2-d case). Dim $Array[5][3] $dim1 = UBound($Array,1);5 $dim2 = Ubound($Array,2);3 MsgBox(1,"",$dim1 & " entries in dimension 1.") MsgBox(1,"",$dim2 & " entries in dimension 2.") $Array[0][0] = "xxx" MsgBox(1,"","'" & $Array[0][0] & "'" & " is the entry 0,0.") $Array[5][3] = "zzz";error: dimension range exceeded MsgBox(1,"","'" & $Array[5][3] & "'" & " is the entry 0,0.") This script is fine until the last 2 lines. Even though I declared the array to be [5][3], when I try to write to the [5][3] entry it doesn't work because it doesn't exist. The last entry would be [4][2]. When you use the UBound command for each dimension you will still get 5 and 3 for the first and second dimension respectively. I would assume this holds true for any number of dimensions. Personally I think this is rather inconvenient and casue me a few problems until I figured this out. I'm just used to working with matrices where the first entry is [1][1]. Hope this helps. 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