Auto-translated
Sorry, I've searched the entire internet and only found a description of my problem in one place, but they didn't offer any advice at all :( Maybe someone here has encountered similar nonsense. I need to add several fields to a dbf file using C++ Builder (6) or Pascal Delphi (6) (via BDE!!!), and the problem is that when I create the dbf table, floating-point fields have only 4 decimal places, but I need more :( I thought this could be solved by setting the Precision property, but no, it always results in only 4 digits after the decimal point, regardless of this property. And if I set the Size property, it actually throws an error for ftFloat. :( In short, a field is created with a size of 20 and 4 decimal places, it's enough to make me bang my head against the wall! What should I do here, how do I set the precision, does anyone know?
int i;
TTable *Table1=new TTable(this);
TTable *Table2=new TTable(this);
if(Form1->OpenDialog1->Execute())
{
Table1->TableName=OpenDialog1->FileName;
Table1->Active=true;
Table2->TableName="temp.dbf";
Table2->TableType=ttFoxPro;
for(i=0; iFieldCount; i++)
{
Table2->FieldDefs->Add(Table1->FieldDefs->Items->Name, Table1->FieldDefs->Items->DataType, Table1->FieldDefs->Items->Size, Table1->FieldDefs->Items->Required);
if(Table1->FieldDefs->Items->DataType==6)
{
Table2->FieldDefs->Items->Precision=8; // How I'm trying to set the number of digits after the decimal point in the dbf file field, but it doesn't work at all
}
}
Table2->CreateTable();
Table2->Active=true;
Table1->First();
Table2->First();
while(!Table1->Eof)
{
Table2->Edit();
Table2->Insert();
for(i=0; iFieldCount; i++)
{
Table2->Fields->FieldByName(Table1->FieldDefs->Items->Name)->AsString=Table1->Fields->FieldByName(Table1->FieldDefs->Items->Name)->AsString;
}
Table2->Post();
Table1->Next();
}
Table1->Active=false;
Table2->Active=false;
}