Sign in to follow this  
Followers 0
AreSin

Dimension

7 posts in this topic

Help me! I have question: How to create 3-dimensional array in AutoIt and possible this?

If possible show me simple example please.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The help file has example of a 2 dimensional array... follow the same convention for upto 64 dimensions IIRC...

Dim $3dArray[$x][$y][$z]

EDIT: I would love to see a practical use of 64 dimensions muttley

Edited by JFee

Regards,Josh

Share this post


Link to post
Share on other sites

The help file has example of a 2 dimensional array... follow the same convention for upto 64 dimensions IIRC...

Dim $3dArray[$x][$y][$z]

EDIT: I would love to see a practical use of 64 dimensions muttley

I can't see a use for more than 3 dimensions. If you need more than 3, AutoIt isn't the proper language because an object is much better suited.

Here is 9 dimensions:

Dim $array[3][2][2][2][2][2][2][2][2]

$array[0][0][0][0][0][0][0][0][0] = "Milky Way"
    $array[0][1][0][0][0][0][0][0][0] = "Solar System"
        $array[0][1][1][0][0][0][0][0][0] = "Earth"
            $array[0][1][1][1][0][0][0][0][0] = "North America"
                $array[0][1][1][1][1][0][0][0][0] = "United States"
                    $array[0][1][1][1][1][1][0][0][0] = "Ohio"
                        $array[0][1][1][1][1][1][1][0][0] = "Columbus"
                            $array[0][1][1][1][1][1][1][1][0] = "Bethel Road"
                                $array[0][1][1][1][1][1][1][1][1] = "2880"

$array[1][0][0][0][0][0][0][0][0] = "Andromeda"

$array[2][0][0][0][0][0][0][0][0] = "Triangulum"

Share this post


Link to post
Share on other sites

Haha, I guess you could call that practical. One hell of a matrix to be created though. I suppose the only time you would ever need that is if you were parsing an XML file or something similar, but even then it is impractical because there are better ways muttley


Regards,Josh

Share this post


Link to post
Share on other sites

Ok guys, i have a question:

Global $Array[4][2][2] ;Declare 3 dimensional array

$Array[0][0][0] = 3 ;Number of array elements

;Filling 1 dimension (or filling 1-st element of the 3 dimensional array?)
$Array[1][0][0] = "A"
$Array[2][0][0] = "a"
$Array[3][0][0] = "1"

;Filling 2 dimension
$Array[1][1][0] = "B"
$Array[2][1][0] = "b"
$Array[3][1][0] = "2"

;Filling 3 dimension
$Array[1][1][1] = "C"
$Array[2][1][1] = "c"
$Array[3][1][1] = "3"

For $i = 1 To $Array[0][0][0]
    MsgBox(0, "First dimension", $Array[$i][0][0])
    MsgBox(0, "Secons dimension", $Array[$i][1][0])
    MsgBox(0, "Third dimension", $Array[$i][1][1])
Next

Above are correct? Or I just filled whole 3 dimensional array?

Share this post


Link to post
Share on other sites

You did not fill the whole array. Try this:

Global $Array[4][2][2];Declare 3 dimensional array

$Array[0][0][0] = 3;Number of array elements

; You forgot these:
$Array[0][0][1] = "<Not Used>"
$Array[0][1][0] = "<Not Used>"
$Array[0][1][1] = "<Not Used>"

$Array[1][0][0] = "A"
$Array[2][0][0] = "a"
$Array[3][0][0] = "Apple"

; ...and forgot these:
$Array[1][0][1] = "B"
$Array[2][0][1] = "b"
$Array[3][0][1] = "Blueberry"

$Array[1][1][0] = "C"
$Array[2][1][0] = "c"
$Array[3][1][0] = "Cherry"

$Array[1][1][1] = "D"
$Array[2][1][1] = "d"
$Array[3][1][1] = "Dates"

$sMsg = "$Array[4][2][2]:" & @CRLF
For $x = 0 To UBound($Array) - 1
    For $y = 0 To UBound($Array, 2) - 1
        For $z = 0 To UBound($Array, 3) - 1
            $sMsg &= "[" & $x & "][" & $y & "][" & $z & "] = " & $Array[$x][$y][$z] & @CRLF
        Next
    Next
Next
MsgBox(64, "Results", $sMsg)

muttley


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

Share this post


Link to post
Share on other sites

PsaltyDS

Thank you! Now I are understand! muttley

Share this post


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
Sign in to follow this  
Followers 0