Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

2D Array Error

$
0
0

My goal is to have an array that contains other arrays... a 2D array.

Array $data[4][3]     0 - Array         0 - Id         1 - Name         2 - Price     1 - Array         0 - Id         1 - Name         2 - Price     2 - Array         0 - Id         1 - Name         2 - Price     3 - Array         0 - Id         1 - Name         2 - Price

I want to structure my array like this so I can pull data from it easily like this... If I want to know the price of the 2nd item in the array I would call for it using $data[1][2].

This is how I tried to do this but it isn't working. Each different attempt gives a different error message. I don't see what I am doing wrong, maybe someone with more experiance than me can pick up on it? Thanks and Please!

#include <Array.au3> Local $data[10] For $i = 0 To 10-1 Step +1    $data[$i] = ["1987", "Toothbursh", "$4.00"] Next _ArrayDisplay($arr)

Error Produced (from console window in SciTe)

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\USER\Desktop\asdas.au3" C:\Users\Mirnes\Desktop\asdas.au3 (7) : ==> Error in expression.: $data[$i] = ["1987", "Toothbursh", "$4.00"] $data[$i] = ^ ERROR >Exit code: 1    Time: 0.230

I then figured that my error was not defining the 2nd dimension in the array so I changed $data[10] to $data[10][3] but it just produced a new error message.
 

#include <Array.au3> Local $data[10][3] For $i = 0 To 10-1 Step +1    $data[$i] = ["1987", "Toothbursh", "$4.00"] Next _ArrayDisplay($arr)

Error Produced (from console window in SciTe)

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\USER\Desktop\asdas.au3" C:\Users\Mirnes\Desktop\asdas.au3 (5) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $data[$i] = ["1987", "Toothbursh", "$4.00"] ^ ERROR >Exit code: 1    Time: 0.222

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>