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 = ARRAY[1..MaxN] OF Float;
You can use a dynamic array.
type
  ColumnType = array of float;

var
  CT: ColumnType;

begin
SetLength(CT,TheSizeYouWant); // TheSizeYouWant is the number of elements (an integer)
  CT[0] := 3.14159; // the first element has index 0
...
  CT[TheSizeYouWant-1] := 2.71828; // the last element;
...
SetLength(CT,0); // set it to nil
end;


--
Jilani KHALDI
---------------------
http://jkhaldi.oltrelinux.com

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to