Mannyfresh31 Posted April 20, 2021 Posted April 20, 2021 (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 expandcollapse popup;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 April 20, 2021 by Mannyfresh31
pseakins Posted April 20, 2021 Posted April 20, 2021 According to this old post you can only pre assign values to a single dimensional array. I believe you need to assign the individual elements programmatically. https://www.autoitscript.com/forum/topic/84377-declare-2d-array-with-pre-initialized-values/ Phil Seakins
TheXman Posted April 20, 2021 Posted April 20, 2021 (edited) Local $aArraym[2][2][2] = [ [ [1,2] , [3,4] ] , [ [4,5] , [7,8] ] ] Edited April 20, 2021 by TheXman Mannyfresh31 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Mannyfresh31 Posted April 20, 2021 Author Posted April 20, 2021 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!!! expandcollapse popup;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
TheXman Posted April 20, 2021 Posted April 20, 2021 You're welcome. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
argumentum Posted April 20, 2021 Posted April 20, 2021 19 minutes ago, Mannyfresh31 said: You got it!!! Now all work fine thanks!!! Is not a rant. I don't rant. Well, maybe. If there was a standard to add "[Solved]" to the title would help me not read, it'd also show that the question was answered. ... just a wish of mine Mannyfresh31 and TheXman 2 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Mannyfresh31 Posted April 20, 2021 Author Posted April 20, 2021 @argumentum ok I'll add the "[Solved]" just to make you happy (; Today is your day baby!! argumentum 1
argumentum Posted April 20, 2021 Posted April 20, 2021 Thanks. It may sound silly but to prefix the [Solved] to the title does help those looking to participate in finding a solution and also helps those looking for a solution Mannyfresh31 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Mannyfresh31 Posted April 20, 2021 Author Posted April 20, 2021 @argumentum You Got It!!! argumentum 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now