Re: [fpc-pascal] How to allocate a 2D array?

2009-01-13 Thread Arjan van Dijk
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

Re: [fpc-pascal] How to allocate a 2D array?

2009-01-12 Thread leledumbo
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;

Re: [fpc-pascal] How to allocate a 2D array?

2009-01-12 Thread Jilani Khaldi
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

Re: [fpc-pascal] How to allocate a 2D array?

2009-01-12 Thread Ivo Steinmann
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] :=

[fpc-pascal] How to allocate a 2D array?

2009-01-12 Thread Arjan van Dijk
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