Computer Science Canada

2-dimensional arrays

Author:  Thuged_Out_G [ Sat Jan 24, 2004 12:11 am ]
Post subject:  2-dimensional arrays

2D ARRAYs

Quote:

var x_y:1..2,1..3


if you think of them as table, it makes sense ....1..2 if the number of collums, and 1..3 is the number of rows

Quote:

------------
|1,1 | 2,1|
------------
|1,2 | 2,2|
------------
|1,3 | 2,3|
------------


this could be useful for storing x and y coords of something.

code:

var x,y,button:int
loop
for i:1..3
Mouse.Where(x,y,button)
if button=1 then
x_y(1,i):=x
x_y(2,i):=y
end if
end for
end loop

for i:1..3
put "Xcoords: ",x_y(1,i)
put "Ycoords: ",x_y(2,i)
end for

Author:  thoughtful [ Sat Jan 24, 2004 12:19 am ]
Post subject: 

nice simple tutorial, yea just to point out, i have used 2D arrays with whatdotcolor (for saving pictures as text files basically getting the color of each dot) , i have also used it with database records. It can be very use ful.

Author:  JayLo [ Sat Jan 24, 2004 9:43 am ]
Post subject: 

there's an alignment problem on this page.

Author:  Andy [ Sat Jan 24, 2004 12:25 pm ]
Post subject: 

ummm i already had a tutorial on arrays that included multi dimensions

Author:  Tony [ Sat Jan 24, 2004 2:23 pm ]
Post subject: 

i fixed the alighnment problem... it often occurs when multiple code tags are used. quote seems to not have such a probelem.

and yes... both dodge and I covered multidimentional arrays in our tutorials


: