Jump to content

2 dimenision array


Recommended Posts

  • 1 year later...

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 post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...