[fpc-pascal]Arrays with Undefined Ranges.

Jon David Sawyer bq at badquanta.net
Thu Mar 27 13:51:14 CET 2003


On Thu, 2003-03-27 at 03:36, Michael Van Canneyt wrote:
> 
> 
> On 26 Mar 2003, Jon David Sawyer wrote:
> 
> > I seem to remember being able to declare something like:
> > MyArray = Array of Byte;
> >
> > Useing "MyArray" as an easy way to get a pointer to a memory location.
> >
> > Now if I do something similar: tQPixelArray = Array of tQPixel; I get a
> > compiler error telling me it Expected [ and got Array.
> >
> > Is there any way of being able to declare an array without a range?
> 
> Only in the 1.1 development compiler. The 1.0 compiler doesn't support
> dynamic arrays.
> 
> 
> >
> > If not is there a index larger than WORD that will work with arrays?
> 
> Yes.
> 
> > QWord will not work and for some reason the compiler does not recognize
> > DWord
> 
> Qword is 64 bit, that will not work, but Cardinal (=DWord) should work.
> 
> But you can just as well use the 'pointer math' approach and declare
> 
> Type
>   tQPixelArray = ^tQPixel;
> var
>   Arr : TQPixelArray;
> 
> Then
>   GetMem(Arr,1000*SizeOf(tqPixel));
>   Arr[0]:=..
>   Arr[1]:=..
> will do what you expect. Only the memory management you must do
> yourself.
> 
> Michael.
> 
The 'Pointer Math' is EXACTLY what I was looking for. Thank you.





More information about the fpc-pascal mailing list