Christian Kaufmann wrote:
var
STable : array of TGIS_FileTIFFSItem
begin
STable[STableSize].Data := Pointer(STable[STableSize].PreAlloc) ;
Make sure you are allocating memory for STable before you access its
elements:
SetLength(STable, ...); // desired element count
And also allocate memory for the PreAlloc field:
SetLength(STable[SomeIndex].PreAlloc, ...); // desired byte count
Unless PreAlloc is being assigned to point at an external preallocated
array instead:
STable[index].PreAlloc := SomeArray;
If I remove the Pointer type cast I still get an error.
Yes, because you are assigning one array type to a different
incompatible array type. Every time you use "array of ...", you are
declaring a new array type. If you have two separate "array of Byte"
declarations, they are separate types, even though they use the same
underlying Byte type. This is covered in the Delphi documentation
http://docwiki.embarcadero.com/RADStudio/en/Structured_Types_(Delphi)#Dynamic_Arrays
If you want to assign the PreAlloc field to the Data field, You need to
change the PreAlloc field to TBytes so it matches the Data field:
type
TGIS_FileTIFFSItem = record
Data : TBytes ;
Dim : Integer;
PreAlloc : TBytes;
end;
--
Remy Lebeau (TeamB)
Connect with Us