Float fields return 0

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
merlin352
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 15.10.2009, 12:20

Float fields return 0

Post by merlin352 »

Hello

I have a problem with 6.6.5 stable, Latarus 0.9.29 beta and FPC 2.5.1.

I have some float fields in a Sqlite3 database. Under Zeos I get only 0 values. A TSQLQuery with a TSQLite3Connection returns the right values.

Has anyone an idea what may be wrong?

thx
merlin352
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 15.10.2009, 12:20

Post by merlin352 »

Hi


I managed to debug ZSysUtils and found whats going wrong. Why this code in :

Code: Select all

function SQLStrToFloatDef(Str: string; Def: Extended): Extended;

.
.
{$IFDEF FPC}
  if OldDecimalSeparator = ',' then
  begin
    DecimalSeparator := OldDecimalSeparator;
    Result := StrToFloatDef(Str, Def);
  end
  else
    Result := StrToFloatDef(Str, Def);
{$ELSE}
    Result := StrToFloatDef(Str, Def);
{$ENDIF}
Why this coding for FPC? The value that SQLite returns has a '.' as decimal separator.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

I have no clue. I did find it myself some weeks ago and I removed it from the sources now. The simple version is in 6.6-patches branch, so will be included in next stable release.

Code: Select all

function SQLStrToFloatDef(Str: string; Def: Extended): Extended;
var
  OldDecimalSeparator: Char;
begin
  OldDecimalSeparator := DecimalSeparator;
  DecimalSeparator := '.';
  if Pos('$', Str) = 1 then
    Str := Copy(Str, 2, Pred(Length(Str)));
  If Str = '' then
    Result := Def
  else
    Result := StrToFloatDef(Str, Def);
  DecimalSeparator := OldDecimalSeparator;
end;
Mark
Image
Post Reply