Sign in to follow this  
Followers 0
vkrisz81

multidimensional arraya

2 posts in this topic

#1 ·  Posted

hello pls help me

i have a list, items separated by kategories

i thought i must have a 3 dimensional array

how can i manage it?

i need an array with this:

0,0,2    2 item in the 0,0 cell

1,0,0, text

1,0,1 integer

1,1,0 item description 1

1,1,1 item description 2

1,1,2 item desc.... x

1,2,0 item2 descrtiption 1

1,2,1 item2 description 2

1,2,2 item desc x

so i want make different arrays in the same arrays as cell value..

if i can

i could make that i make 5 item array, i can pass an other array to an existing array cell, so my aerray will contain 4 cell and 1 array object, but i dont know how can i define..

ty

 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

1 hour ago, vkrisz81 said:

....

i could make that i make 5 item array, i can pass an other array to an existing array cell, so my aerray will contain 4 cell and 1 array object, but i dont know how can i define..

ty

Most situations can be dealt with using a multi-line and multi-column 2D array instead of using a 3D array.
A 1D array, or 2D array, can be embedded in a 1D, or 2D array's cell (or item).

The example shows a 1D array embedded in a 1D array.  And, an example of the complexity involved with using 3D arrays.

#include <Array.au3>

Local $aItem4[4] = [40, 41, 42, 43]
Local $Array[5] = [0, 1, 2, $aItem4, 4] ; The item of $Array with array index 3, or, the 4th item of $Array is the array, $aItem4.

_ArrayDisplay($Array)
_ArrayDisplay($Array[3]) ; Display 4th item.
ConsoleWrite(($Array[3])[3] & @CRLF)
;--------------------------------------------------------------------------------------

; From https://www.autoitscript.com/forum/topic/90213-embed-data-in-script-no-data-file/?do=findComment&comment=648808
; 3 dimensional array
Local $array2x3x4[2][3][4] = [[['[0][0][0]', '[0][0][1]', "[0][0][2]", '[0][0][3]'], _
        ['[0][1][0]', '[0][1][1]', '[0][1][2]', '[0][1][3]'], _
        ['[0][2][0]', '[0][2][1]', '[0][2][2]', '[0][2][3]']], _
        [['[1][0][0]', "[1][0][1]", '[1][0][2]', '[1][0][3]'], _
        ['[1][1][0]', '[1][1][1]', '[1][1][2]', '[1][1][3]'], _
        ['[1][2][0]', '[1][2][1]', "[1][2][2]", '[1][2][3]']]]

Local $sRes = "Contents of $array2x3x4 array" & @CRLF & @CRLF
For $x = 0 To 1
    For $y = 0 To 2
        For $z = 0 To 3
            $sRes &= "$array2x3x4[" & $x & "][" & $y & "][" & $z & "] = " & _
                    $array2x3x4[$x][$y][$z] & @CRLF
        Next
    Next
Next
MsgBox(0, "Display $array2x3x4", $sRes)

 

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