Thanks all!This one works!Arjan>He wants 2D dynamic arrays, let's give him one:>type> TMyArray = array of array of Float;>var> MyArray: TMyArray;>begin> SetLength(MyArray,Width,Height); // Valid index now:>[0..Width-1,0..Height-1]> // Do something with MyArray> // No deallocation needed, the c
He wants 2D dynamic arrays, let's give him one:
type
TMyArray = array of array of Float;
var
MyArray: TMyArray;
begin
SetLength(MyArray,Width,Height); // Valid index now:
[0..Width-1,0..Height-1]
// Do something with MyArray
// No deallocation needed, the compiler does this for you
end;
Arjan van Dijk wrote:
Hi!
In my code I often use 2D arrays.
Until today, I kept the maximum dimension fixed to 400 * 300 points.
How can I make allocatable columns of ARBITRARY size?
For simplicity here a 1D reduction of the problem:
This is what I have:
CONST
MaxN = 400;
TYPE
ColumnType
you can try
var
YourArray, Row: PFloat;
Width: Integer;
Height: Integer;
// alloc array
GetMem(YourArray, Width*Height*Sizeof(Float));
// access point (X, Y), while X in [0,Width-1] and Y in [Y, Height-1]
YourArray[X + Y*Width] := ...
// access row (Y)
Row := @YourArray[Y*Width];
Row[X] :=
Hi!
In my code I often use 2D arrays.
Until today, I kept the maximum dimension fixed to 400 * 300 points.
How can I make allocatable columns of ARBITRARY size?
For simplicity here a 1D reduction of the problem:
This is what I have:
CONST
MaxN = 400;
TYPE
ColumnType = ARRAY[1..MaxN] OF Floa