[fpc-pascal] fillword with multidimensional dynamic array.
Luis Fernando Del Aguila Mejía
luis3000 at ec-red.com
Fri May 27 21:49:38 CEST 2011
Hello
How do I fill a multidimensional dynamic array, with fillWord?
Var a:array of array of word;
m,n:byte;
i,j:byte;
Begin
m:=3; //array 3 x 3
n:=3;
SetLength(a,m,n);
for i:=0 to m-1 do //How this block replace con fillword ?
for j:=0 to n-1 do
a[i,j]:=15;
for i:=0 to m-1 do
for j:=0 to n-1 do
Writeln('a[',i,',',j,'] : ',a[i,j]);
End.
With manual dynamic array did this:
Var a:^word;
m,n:byte;
i,j:byte;
Begin
m:=3; //array 3 x 3
n:=3;
getmem(a,m*n*2); // word = 2 bytes
fillword(a^,m*n,15);
for i:=0 to m-1 do
for j:=0 to n-1 do
Writeln('a[',i,',',j,'] : ',a[i*m+j]);
freemem(a)
End.
thanks.
More information about the fpc-pascal
mailing list