[fpc-pascal] Adding a array of float in ressource and use it ?
Michael Van Canneyt
michael at freepascal.org
Mon Mar 6 12:07:25 CET 2017
On Mon, 6 Mar 2017, fredvs wrote:
> Define "much less success". How are you writing the array and how are you
> reading it?
>
> Hello and thanks for answer.
>
> Here how the array is written:
>
> var
> buffer : array of float;
> ....
> FileBuffer.Data := TFileStream.Create(filename,fmCreate);
> FileBuffer.Data.Seek(0, soFromBeginning);
> FileBuffer.Data.WriteBuffer(buffer[0],Length(Buffer));
>
> The result is OK if integer 16/32 bit inside the buffer.
> If data inside the buffer is float 32 bit, result is a file of... 2
> octets...
You must write
FileBuffer.Data.WriteBuffer(buffer[0],Length(Buffer)*Sizeof(Float));
Because for a dynamic array, length returns the length in elements, not in bytes.
Michael.
More information about the fpc-pascal
mailing list