[fpc-pascal] Custom dataset help request: ftCurrency/ftDateTime returns weird data

Marco van de Voort marcov at stack.nl
Fri Oct 4 15:43:33 CEST 2013


In our previous episode, Reinier Olislagers said:
> missing something.
> 
> The relevant code:
> function TTransactionDataset.GetFieldData(Field: TField; Buffer:
> Pointer): boolean;
> ...
>   Result := true;
>   case Field.FieldName of
>     'HashID': StrPLCopy(Buffer, FTransactionList[FCurrentRecord].HashID,
> Field.Size);
>     'BookDate': TDateTime(Buffer^) :=
> FTransactionList[FCurrentRecord].BookDate;
>     'Amount': Currency(Buffer^) := FTransactionList[FCurrentRecord].Amount;

In surprise that it compiles. If buffer is an (untyped) pointer, buffer^ is
a byte afaik (just sizeof() it).  You cast that byte to currency and then
use it as lvalue? 

Maybe I miss some weird FPC ability there, and the currency cast makes it
take more bytes, but I would expect

pcurrency(buffer)^:=




More information about the fpc-pascal mailing list