Jump to content

Recommended Posts

Posted (edited)

Please help with this 3D Array the first example works the secound doesn't.

Need help to understand how Arrays work.

Many thanks in advance

;First Example

Dim $aArray[2][2][2]

$aArray[0][0][0] = 1
$aArray[0][0][1] = 2
$aArray[0][1][0] = 3
$aArray[0][1][1]  = 4

$aArray[1][0][0] = 5
$aArray[1][0][1] = 6
$aArray[1][1][0] = 7
$aArray[1][1][1] = 8


For $a = 0 to 1
    for $b = 0 to 1
        for $c = 0 to 1

ConsoleWrite($aArray[$a][$b][$c] & @CRLF)

        Next
    Next
Next


;Secound Example

Local $aArraym [2][2][2]=[[[1,2,],[3,4],[5,6],[7,8]]]




For $a = 0 to 1
    for $b = 0 to 1
        for $c = 0 to 1

ConsoleWrite($aArraym[$a][$b][$c] & @CRLF)

        Next
    Next
Next

 

Edited by Mannyfresh31
Posted (edited)
Local $aArraym[2][2][2] = [ [ [1,2] , [3,4] ] , [ [4,5] , [7,8] ] ]

 

Edited by TheXman
Posted
7 minutes ago, TheXman said:
Local $aArraym[2][2][2] = [ [ [1,2] , [3,4] ] , [ [4,5] , [7,8] ] ]

 

You got it!!! Now all work fine thanks!!!

;First Example

Dim $aArray[2][2][2]

$aArray[0][0][0] = 1
$aArray[0][0][1] = 2
$aArray[0][1][0] = 3
$aArray[0][1][1]  = 4

$aArray[1][0][0] = 5
$aArray[1][0][1] = 6
$aArray[1][1][0] = 7
$aArray[1][1][1] = 8


For $a = 0 to 1
    for $b = 0 to 1
        for $c = 0 to 1

ConsoleWrite($aArray[$a][$b][$c] & @CRLF)

        Next
    Next
Next


;Secound Example

Local $aArraym [2][2][2]=[[[1,2],[3,4]],[[5,6],[7,8]]]




For $a = 0 to 1
    for $b = 0 to 1
        for $c = 0 to 1

ConsoleWrite("Here I come " & $aArraym[$a][$b][$c] & @CRLF)

        Next
    Next
Next

 

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
×
×
  • Create New...