Field-Type TDbf ftFloat seems not workly correct.
The result on a create Table with this Fieldtype,
we get a Fieldtype 'Numerical' respective 'ftInteger
and there a no possibility to perform decimal places in it.
MyDbf.FieldDefs.Add('ZAHL_FLOAT', ftFloat, 10, true).
Now I have the Piece of Code:
procedure TForm1.DBF_Datei_Neu(sender : TObject);
begin
MyDbf := TDbf.Create(nil);
try
(* Now we use an absolute Path to "DATA"-Directory *)
MyDbf.FilePathFull := 'C:\PROJEKTE\PASCAL\DBA\DATA' + DirectorySeparator;
(* Wir want to create an compatible DBASE4 Table *)
MyDbf.TableLevel := 4;
MyDbf.Exclusive := true;
MyDbf.TableName := 'testpasc.dbf';
(* For this wie need the Unit DB *)
with MyDbf.FieldDefs do
begin // Here are my own-named DBASE-Fieldtypes
Add('ID', ftInteger, 3, true); // N 3,0 NoIdx
Add('NAME', ftString, 20, true); // C 2 NoIdx
Add('ZAHL_BYTE', ftSmallInt, 3, true); // N 3 NoIdx
Add('ZAHL_INT', ftInteger, 6, true); // N 6 NoIdx
...
Add('ZAHL_FLOAT', ftFloat, 10, true); // G 10,3 NoIdx
...
end; (* of with MyDbf.FieldDefs *)
MyDbf.CreateTable;
MyDbf.Open;
MyDbf.AddIndex('id', 'ID', [ixPrimary, ixUnique]);
(* We fill the first Record *)
MyDbf.Append; // Create an Record
MyDbf.FieldByName('ID').AsInteger := 1;
MyDbf.FieldByName('NAME').AsString := 'Jesus Christ';
MyDbf.FieldByName('ZAHL_BYTE').AsInteger := 255;
MyDbf.FieldByName('ZAHL_INT').AsInteger := 32767;
MyDbf.FieldByName('ZAHL_FLOAT').AsFloat := 3.14159;
MyDbf.Post; // Important for Store of the Record and Continuing
end; (* of with MyDbf.FieldDefs *)
...
finally
MyDbf.Free;
end; (* of try-finally *)
end; (* of procedure TForm1.DBF_Datei_Neu *)
If we later load the Table in originally DBASE 4 , which we created with Component TDbf ,
we see that the field 'ZAHL_FLOAT' is always of Type 'Numerical', not of Type 'Gleitkomma'
(it's a german DBASE, i don't know the correct english naming of this type).
And we see in Field ZAHL_FLOAT only the Number 3 - without decimal places.
What should I do?
Is it really a bug in the Component TDbf ?
Thanks for your help and answers,
PascalGuru