Forum > Databases

TDBF fails to open DBF files with ftfloat correctly

(1/3) > >>

magu:
Hello,

It appears that TDbf fails to correctly read floating numbers, I am not sure why (and i'm not sure if this problem is exclusive to me).
for example in the attached dbf in row 1 the values should be "12345.67" and "201.14" but instead are displayed as "1.2E3" and "2". While in row 2 the values "345.67" and "12.114" are displayed as 34 and 1
I have tried to set TDbf.TableLevel manually to see if this makes a difference but the TableLevel changes when you open the DBF.
The DBF fields are defined as numeric with size(24) and Precision(3).
However when opening the file TDF does not appear to recognise these attributes and I'm not sure how to change them programmatically one the dbf file is opened.
Thanks

wp:
In the attached project I played a bit with the dbf float field. I don't know if it is a bug (I doubt) or a matter of definition. It looks to me that the "Size" in the fielddef is largely ignored, and the "Precision" determines the total count of digits - not just the decimal places. So, when you say the Precision is 3 then you only have 3 digits to display the value, and I would expect 12345.67 to be displayed as 1.2E4 (three digits: 1, 2, and 4). But you say it is displayed a 1.2E3 (exponent smaller by 1), and I can confirm that when I display your table in MyDbfStudio. So what is going on here? Can you show the code how you create the table and in particular the fielddefs?

magu:
The database was taken from a legacy system that I am trying to transfer to a more modern db.
So it could be some strange dialect however Ms Access reads the file correctly (if it helps the MS connection string automatically generated states: "dBASE III;HDR=NO;IMEX=2;ACCDB=YES;").
I have tried to open it with another program (DBF Viewer 2000 - dbf2002.com) and this worked correctly.

The fields have been reported as being the following:

Name       Type    Size Dec
DRef    Character    8    0
SAMPLEDATE Date    8    0
Notes    Character    30    0
Amt2    Numeric    24    2
AMOUNT    Numeric    25    3

magu:
The issue seems to be with the Numeric Size.
Lowering the Numeric size to a value under 18 (and increasing the second attribute - which is precision) will provide a correct result.

The issue arises when the Numeric Size is greater than 18.
Ms Access reads the value correctly by treating the number as a Double.

Having seen the TDbf fields source it appears that the numeric size is limited (there) to 18 digits, but I'm not sure how to extend this / treat this as a special case or flag an error...

winni:
Hi

In dBase III the maximum length of a numeric field is restricted to 15 digits - perhaps that is the reason for the error.

Winni

Navigation

[0] Message Index

[#] Next page

Go to full version