Hello,

I have a quick question on assignation of multidimensional arrays.

I wish to set up an array of 42 x 6 (42 rows by 6 columns). However, I'm unclear on how to do this. Should I try the following?

m:int32[42,6];

And then to assign a number (say, 6) to an array part, do I then do the following?:

m[1,1]:=6;

Basically, the numbers correspond as follows:

m=nextroom

Room should be anything, in this case, between 1 and 42. Direction should be 1 through 6, with each number meaning the following:

1=north
2=south
3=east
4=west
5=up
6=down

Hence the 42,6.

So to set individual parts of m, do I then do:

m[1,2]:=6;

after all the code you suggested?

All I want to do is to create a 42 x 6 array, and have access to m
[1,1],m[1,2],m[1,3],m[1,4],m[1,5],m[1,6],m[2,1],m[2,2]...etc right on
through to 42.

I need to be able to do, say, m[41,3]:=37;

What am I missing here?

Regards,

Paul Panks
dunric@y...



--- In aoaprogramming@yahoogroups.com, "mistronr1" <mistronr1@y...>
wrote:
> Hi
> first off all m is 7x6 array, wich is 42 elements & not 42x6
> elements.
>
> Index in an array start's with 0, that is m[0,0] if you want to
> assign value to the first possition in your array.
>
> what you did is create an array m 7x6 and gave initial values to
> every position, starting with m[0,0] := 1; m[0,1]:=2; ... m
[6,7]:=28;
> Here is an example on how to initialize a 7x6 array & print it:
>
> /********START***********************/
> program MultiArray;
>
> #include( "stdlib.hhf" );
>
> const
> row:int32 :=7;
> col:int32 :=6;
>
>
> static
> i: int32;
> j: int32;
>
> ary: int32;
>
>
> begin MultiArray;
>
> mov( 0, i );
> while( i < col ) do
> mov( 0, j );
> while( j < row ) do
> mov( i, ebx );
> shl( 3, ebx );
> add(j,ebx);
> mov( ebx,ary );
> inc( j );
>
> endwhile;
> inc( i );
> endwhile;
>
> mov( 0,i );
>
> while( i < col ) do
> mov(0,j);
> while( j < row ) do
> mov( i, ebx );
> shl( 3, ebx );
> add(j,ebx);
> stdout.put(ary," ");
> inc( j );
> endwhile;
> inc( i );
> stdout.put( nl );
> endwhile;
>
> end MultiArray;
> /*****************END***************/
>
> I didn't put any comments coz everything is explaind in Chap 4.6,
> 4.7 & 4.8.
> Best Regards
>

Regards,

Paul Panks
dunric@yahoo.com
Posted on 2003-04-30 21:34:02 by Paul Panks
In HLA, multi-dimensional arrays are a pain in the rumpus to implement. Would it be possible, say, just to multiply the two cells together and set up if...then statements to act on them?
Example:

m1[1*2]:=5

This is really cell 1,2 and it equals 5.

I've set it up where if there are duplicates (e.g. 6*2, 12*1, 4*3, etc.) that they get assigned to another array, i.e.:

m1[6*2]:=11
m2[3*4]:=5
m3[12*1]:=11

I then act on each with an individual IF...THEN statement like so:

if(m1>0) then
room=m1;
elseif(m2>0) then
room=m2;
elseif(m3>0) then
room=m3;
endif;

This seems to me like it would work, but it takes a lot of work because it appears as though assembly...argh...multi-dimensional arrays in assembly appear to be difficult to implement.

Regards,

Paul Panks
dunric@yahoo.com
Posted on 2003-05-02 12:38:09 by Paul Panks

In HLA, multi-dimensional arrays are a pain in the rumpus to implement. Would it be possible, say, just to multiply the two cells together and set up if...then statements to act on them?
Example:

m1[1*2]:=5

This is really cell 1,2 and it equals 5.


This seems to me like it would work, but it takes a lot of work because it appears as though assembly...argh...multi-dimensional arrays in assembly appear to be difficult to implement.



Take a look at:
http://webster.cs.ucr.edu/Page_hla/HLADoc/HTMLDoc/HLAStdlib.html#pgfId-1041617

HLA's arrays module lets you access array elements with much less effort than is normally required (of course, there is a slight performance penalty for this extra effort, but it is slight).

e.g.,

array.index( ebx, m1, i, j );
mov( 5, (type dword );

does what you want (assuming i=1 and j=2).
Cheers,
Randy Hyde
Posted on 2003-05-02 22:55:46 by rhyde