Jump to content

_ArrayAdd() w/ Multidimensional arrays


Recommended Posts

Well, basically what I want to know is if this is legitimate:

Dim $MultiA[1][1]
...
Dim $HolderArray[1] = [""]
_AddArray($MultiA,$HolderArray)

Basically, I'm adding to the first dimension as I go, but I need to make sure that the AutoIt knows it's another array.

I've tried this and it's not working, so I want to know if the problem exists with something else.

Link to comment
Share on other sites

Hi! You can adding a new value in the array manualy:

#include <Array.au3>

Dim $aTest[2][2]

$aTest[0][0] = 1

$aTest[1][0] = "Brian"
$aTest[1][1] = "John"

_ArrayDisplay($aTest, "Previous")

;Adding new element in 2 dimensional array
$aTest[0][0] += 1
ReDim $aTest[$aTest[0][0] + 1][2]

$aTest[2][0] = "Larry"
$aTest[2][1] = "Rick"

_ArrayDisplay($aTest, "After adding")
Link to comment
Share on other sites

Hi! You can adding a new value in the array manualy:

#include <Array.au3>

Dim $aTest[2][2]

$aTest[0][0] = 1

$aTest[1][0] = "Brian"
$aTest[1][1] = "John"

_ArrayDisplay($aTest, "Previous")

;Adding new element in 2 dimensional array
$aTest[0][0] += 1
ReDim $aTest[$aTest[0][0] + 1][2]

$aTest[2][0] = "Larry"
$aTest[2][1] = "Rick"

_ArrayDisplay($aTest, "After adding")
Thanks. I was actually thinking of doing that before.

Now I'll try it out.

EDIT: Hold on though.

Does this mean that every $aTest[$n] will have the amount of elements as that of the biggest $aTest[$n][$n2]?

What I really have is an array of arrays, with each array having a varying size.

Edited by PCode
Link to comment
Share on other sites

Thanks. I was actually thinking of doing that before.

Now I'll try it out.

EDIT: Hold on though.

Does this mean that every $aTest[$n] will have the amount of elements as that of the biggest $aTest[$n][$n2]?

What I really have is an array of arrays, with each array having a varying size.

An array has a fixed size in each dimension. If you want 10 rows with 2 columns in some rows, but 5 columns in others, you will have to declare (or ReDim) with [10][5] and just ignore the unused elements.

Another option you have is nested arrays, where a single element in one array contains another array. This can get complicated and confusing, but it can work. One limitation is that the nested array cannot be directly addressed, it must first be read out to a simple array before operating on it it.

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...