Jump to content

Recommended Posts

Posted

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

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Posted (edited)

#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

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

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

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Posted

Something like this >>

#include <Array.au3>

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

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

  On 8/23/2011 at 8:24 PM, 'guinness said:

Something like this >>

#include <Array.au3>

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

Okay, Thanks! :mellow: 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

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Posted (edited)

There's also the AutoIt Wiki about Arrays!

  Quote

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

OK :mellow: Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

  On 8/23/2011 at 8:27 PM, 'guinness said:

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 :mellow: 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

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Posted (edited)

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

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

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"]]

Posted

  On 7/27/2010 at 1:02 PM, 'iEvKI3gv9Wrkd41u said:

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 ...
 

Posted (edited)

  On 8/24/2011 at 3:11 AM, 'LaCastiglione said:

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.

  On 7/7/2011 at 10:15 AM, 'LaCastiglione said:

All banana are fruit but not all fruit are banana.

---

  On 8/24/2011 at 9:34 AM, 'JohnOne said:

<puts orthopedic shoes on>

:mellow:

:) 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 ...
 

  • Moderators
Posted

JohnOne,

  Quote

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] :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

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...