[DUG] Create new table from existing one.

2009-02-17 Thread Marshland Engineering
I am using Dbase tables and when I create a new table from and existing one, 
the real number fields are being created as equivalent to integers. I was using 
TDBF from Sourceforge, so I reverted back to Delphi's own tables and I have 
exactly the same problem.

Using the Database desktop with the newly created file, all the real numeric 
fields have field names but incorrectly shown with no length. 
 Does Dbase have to have a certain numeric field length to work ?  
Probably not, because making the file manually, as below, should have then 
worked. 

Both options below make no difference.

   tblSave := TTable.Create(Application);
   with tblSave do begin
  Active:=False;
  TableType:=ttDBase;
  TableName := fFiles.eDir.text+'\'+fFiles.eFile.text+'.dbf';
  Name:=fFiles.eFile.text;

=  FieldDefs.Assign(dm.tblOper.FieldDefs);  // Automatically assign 

=  with FieldDefs do begin  // Manually Assign
 Clear;
 for i := 0 to (dm.tblOper.FieldCount -1) do Begin
if dm.tblOper.Fields[i].Datatype=ftString then
 Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), ftString, 30, 
False);
if dm.tblOper.Fields[i].Datatype=ftSmallint then
 Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), ftSmallint, 0, 
False);
if dm.tblOper.Fields[i].Datatype=ftMemo then
 Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), ftMemo, 0, False);
if dm.tblOper.Fields[i].Datatype=ftFloat then
 Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), ftFloat, 0, False);
  end;
  end;  

Look like the only way I can get a new file with the same structure is to use a 
dos copy, open the file and delete all the records.

Any other suggestions ?

Thanks Wallace

 ___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Re: [DUG] Create new table from existing one.

2009-02-17 Thread Neven MacEwan
Wallace

Is their any overriding reason you are using dBase tables? Its a bit dated?

If I was doing a single user app, that didn't interact with an external 
report writer etc, I'd use kbmMemtable
otherwise its difficult to go past MS SQL free versions (or Firebird) 
which being SQL servers give you quite a bit more
'grunt'

hat version of Delphi are you running?

Neven
 I am using Dbase tables and when I create a new table from and 
 existing one, the real number fields are being created as equivalent 
 to integers. I was using TDBF from Sourceforge, so I reverted back to 
 Delphi's own tables and I have exactly the same problem.
  
 Using the Database desktop with the newly created file, all the real 
 numeric fields have field names but incorrectly shown with no length. 
 Does Dbase have to have a certain numeric field length to work ?  

 Probably not, because making the file manually, as below, should have 
 then worked.

 Both options below make no difference.
  
tblSave := TTable.Create(Application);
with tblSave do begin
   Active:=False;
   TableType:=ttDBase;
   TableName := fFiles.eDir.text+'\'+fFiles.eFile.text+'.dbf';
   Name:=fFiles.eFile.text;
  
 =  FieldDefs.Assign(dm.tblOper.FieldDefs);  // Automatically assign 

 =  with FieldDefs do begin  // Manually Assign
  Clear;
  for i := 0 to (dm.tblOper.FieldCount -1) do Begin
 if dm.tblOper.Fields[i].Datatype=ftString then
  Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), ftString, 
 30, False);
 if dm.tblOper.Fields[i].Datatype=ftSmallint then
  Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), 
 ftSmallint, 0, False);
 if dm.tblOper.Fields[i].Datatype=ftMemo then
  Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), ftMemo, 
 0, False);
 if dm.tblOper.Fields[i].Datatype=ftFloat then
  Add(trim(copy(dm.tblOper.Fields[i].Name,8,10)), ftFloat, 
 0, False);
   end;
   end; 
 Look like the only way I can get a new file with the same structure is 
 to use a dos copy, open the file and delete all the records.
  
 Any other suggestions ?
  
 Thanks Wallace
  
  
 

 ___
 NZ Borland Developers Group - Delphi mailing list
 Post: delphi@delphi.org.nz
 Admin: http://delphi.org.nz/mailman/listinfo/delphi
 Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
 unsubscribe

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe


Re: [DUG]: create

1999-03-28 Thread Aaron Scott-Boddendijk

Say I want to create the new panel in my current code, but not on the same form...
Q is; how to create and free such a beast so that it is independent of the
current mainform. It needs to be a 640x480 panel which I will actually
locate off the screen.
Does it have to me made showmodal??


The code below makes a form and a panel and shows the form offscreen giving a handle
to the panel (called ThePanel) so that you can alter its behaviour assign events and 
such...

Creation and destruction are performed at entry and exit of the application... I dunno 
if this
is what you want or not... Note that it isn't showmodal so it should be fine... There 
might
be more management of the offscreen form though...

unit Unit1;

interface
uses
  ExtCTrls,Forms;

var
  ThePanel :TPanel;

implementation
var
  HolderForm :TForm;

initialization
  HolderForm := TForm.Create(nil);
  with HolderForm do begin
Left := -1000;
Top := -1000;
Show;
  end;
  ThePanel := TPanel.Create(HolderForm);
  with ThePanel do begin
Parent := HolderForm;
Width := 640;
Height := 480;
  end;
finalization
  HolderForm.Free;
end.

--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax


---
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
  Website: http://www.delphi.org.nz