# Understanding multidimesional arrays

## Recommended Posts

I search this a few times using varying forms of "multidimesional arrays" and nothing turned up, so I'm gonna go ahead an ask. Can someone help me understand multidimesional arrays and show me how to set one up? A HIGHLY commented example script would also work. Thanks.

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

##### Share on other sites

```#include <Array.au3>

Local \$1DArray[3] = ["el-0/col1", "el-1/col1", "el-2/col1"]; manually create a one dimensioanal array with 3 elements
_ArrayDisplay(\$1DArray, "1D Array") ;Show it
Local \$2DArray[3][2] ; this is declaring a 2D array, with 3 elements and 2 colums

For \$i = 0 To 2
\$2DArray[\$i][0] = \$1DArray[\$i] ;add the same elements fron first 1D array to colum 0 of our 2D array
\$2DArray[\$i][1] = "el-" & \$i & "/col1";; add values for the  second colum (colum 1)
Next

_ArrayDisplay(\$2DArray, "2D Array")```

Edited by JohnOne

Monkey's are, like, natures humans.

##### Share on other sites

So basically it's like a standard array but each element has more details added by another dimension? Also, how would I manually set up a multidimensional array compared to \$array[3] = ["1", "2", "3"]?

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

##### Share on other sites

Something like this >>

```#include <Array.au3>

Local \$aArray[3][2] = [[2], ["Test", "Test"], ["Test", "Test"]]
_ArrayDisplay(\$aArray)```
##### Share on other sites

```#include <Array.au3>

Local \$2DArray[2][2] = [[0,1],[0,1]]

_ArrayDisplay(\$2DArray, "2D Array")```

Monkey's are, like, natures humans.

##### Share on other sites

Something like this >>

```#include <Array.au3>

Local \$aArray[3][2] = [[2], ["Test", "Test"], ["Test", "Test"]]
_ArrayDisplay(\$aArray)```

Okay, Thanks! I'll probably use multidimensional arrays sometime in the future. IDK when though.

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

##### Share on other sites

There's also the AutoIt Wiki about Arrays!

I'll probably use multidimensional arrays sometime in the future.

OK Edited by guinness
##### Share on other sites

There's also the AutoIt Wiki about Arrays!

Yeah and the 4-dimensional array is a bit confusing and intimidating to me, as it is huge, but I'm highly sure I understand Multidimensional arrays now. Thanks for all the help guys.

@Guiness what's for? I don't know why you posted it... and I don't know how to respond to it...

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

##### Share on other sites

To me an 4D array is like two tables.. where every element of the first table point to another table

##### Share on other sites

Its not really a 4D array its just 2 dimensional Rows and colums, just more of them.

A 3D array would be something like

\$3DArray[3][3][3], but I'm unsure if autoit3 supports that sort of madness, I'd visualize that as a rubiks cube type thing.

Monkey's are, like, natures humans.

##### Share on other sites

Never say never, but for most a two-dimensional array is suffice for most applications.

Edited by guinness
##### Share on other sites

I like to get out the hookah and put on Ravi Shankar records when I consider anything "multi-dimensional".

Seriously, like they said, it's still just a basic flat array with some fancy referencing tacked on allowing you to group, or logically organize and retrieve the data.

A simple array like:

\$aNames[8] = ["Bob", "Carol", "Ted", "Alice", "Fido", "Fifi", "Mickey", "Minnie"]

is still the exact same 8 fields of data whether it's defined as \$aNames[4][2] or \$aNames[2][4] or \$aNames[2][2][2].

But had I a need to organize humans and non-humans seperately, then I might define the array like this:

\$aNames[2][4] = [["Bob", "Carol", "Ted", "Alice"],["Fido", "Fifi", "Mickey", "Minnie"]]

Elements [0][0-3] would be the humans, and elements [1][0-3] the critters.

Or if I wanted to keep the "couples" together, then:

\$aNames[4][2] = [["Bob", "Carol"],["Ted", "Alice"],["Fido", "Fifi"],["Mickey", "Minnie"]]

##### Share on other sites

Index ___ Array_GetDefinition

Generate AutoIt array definition code for a given array.

- Any array dimensions.

- Code generation tool/function.

- Base variable types only. (String and Number type's)

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...

##### Share on other sites

I guess you could think of a multidimensional array as an array within an array. Each array element contains an array.

He, bah.

Liked this one better.

All banana are fruit but not all fruit are banana.

---

<puts orthopedic shoes on>

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...

##### Share on other sites

Ah! but all bananas are not fruit?

In fact no bananas are fruit, given that a banana is a herb.

Monkey's are, like, natures humans.

##### Share on other sites

• Moderators

JohnOne,

a banana is a herb

[Off Topic][Pedant Mode]

The yellow thing you peel and eat is most definitely a fruit - although as commercially grown banana plants are sterile, the "seeds" are merely the little black specks within the flesh.

It is the banana plant on which the fruits grow which is technically a herb as the stem does not contain true woody tissue.

[/Pedant Mode][/Off Topic]

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

<puts orthopedic shoes on>

Monkey's are, like, natures humans.

##### Share on other sites

Man this topic got off-topic quickly...

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...