[fpc-pascal]Arrays with Undefined Ranges.
Michael Van Canneyt
michael.vancanneyt at wisa.be
Thu Mar 27 09:36:24 CET 2003
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.
More information about the fpc-pascal
mailing list