[Lazarus] FloatToStrIntl

Pavel Řezníček cigydd at gmail.com
Sat Sep 13 22:41:54 CEST 2008


Michael Van Canneyt napsal(a):
> On Sat, 13 Sep 2008, Pavel Řezníček wrote:
>
>   
>> Michael Van Canneyt napsal(a):
>>     
>>> On Sat, 13 Sep 2008, Pavel Řezníček wrote:
>>>
>>>   
>>>       
>>>> Hello all,
>>>>
>>>> On Lazarus v0.9.25 r16541 i386-win32-win32/win64, I have the following 
>>>> problem.
>>>>
>>>> I access an SQLite3 database. There I have a column defined as 
>>>> numeric(3), it means, 3 whole number digits and no decimal places. The 
>>>> table has to be synchronised with PostgreSQL using the same table name 
>>>> and column names. Therefore the column definition is simply taken from 
>>>> the PostgreSQL definition.
>>>>
>>>> The data is maybe stored correctly in the database but when I call the 
>>>> AsString property on that field, I don't get e. g. '14' as expected but 
>>>> '0,0014'.
>>>>     
>>>>         
>>> And this is correct. 
>>>
>>> The string is formatted according to the default float format. 
>>> The underlying data format is not relevant. If you want this,
>>> set the DisplayFormat property to something FormatFloat understands.
>>> (I suppose '000')
>>>
>>> Michael.
>>>       
>> Another comment:
>>
>> DisplayFormat has no effect here because the field is considered to be 
>> a TBCDField and there DisplayFormat isn't used. Or am I wrong?
>>
>> CurrToStr just calls FloatToStrF with some default parameters. No chance 
>> to use my own format from the point of view of the "user programmer" - 
>> until I go around the AsString property.
>>
>> - fields.inc, line 2212:
>>
>> function TBCDField.GetAsString: string;
>>
>> var c : system.currency;
>>
>> begin
>>   If GetData(@C) then
>>     Result:=CurrToStr(C)
>>   else
>>     Result:='';
>> end;
>>     
>
> This is a bug and should be corrected.
>
> Michael.
OK, I'm going to file a bugreport.

Pavel



More information about the Lazarus mailing list