2D Arrays.

BlitzMax Forums/BlitzMax Beginners Area/2D Arrays.

Hay all.

ok so I needed to make a 2D Array, now TBH with you I couldnt get it to work, I was trying something like this.

Global MyArray:int[][]=[[1,2][3,4]]
Print MyArray[1][1]

What I was expecting was "3" as an output or "1 3" but what I got was "4" the above example is taken from another array post in which he used strings but the idea is the same.

Anyway What I actually want would look like this in Blitz3D.

Dim Array$(2,2)
Array$(1,1)="1"
Array$(1,2)="2"
Array$(2,1)="3"
Array$(2,2)="4"
So if I wanted 3 Id do this.

Print Array$[2,1]

I have now worked out how to do this in Max and thought I would share it.

Global Hscore$[5+1,2+1]
For looper%=1 To 5
	Hscore$[looper,1]="Name-"+String(looper)
	Hscore$[looper,2]=String(100*looper)
Next

For looper%=1 To 5
	Print Hscore[looper,1]+":"+Hscore[looper,2]
Next


What the above Bmax code does is create a 2D Array, with 5 Elements in the first section and 2 in the last, I will be using this as a high score array, 5 positions and storing a name and socre in each.

My question at this point is what the hell is the +1 for. ??

GOOD TIP <<<<

To get the above code what I did was code it in B3D and then imported it to max to see how it wanted it done.