> To physically remove records from a dBASE table file that have been soft-
> deleted, you would need to use the BDE function DbiPackTable. The stock
> TTable component includes only those table features and operations com-
> mon to all table types natively supported. Idiosyncracies of only one
> table type were not provided for, and require special action. These soft-
> deletes are specific to dBASE tables.
> Here is an example of a unit that makes a call to the DbiPackTable func-
> tion. As when calling any BDE function, the BDE wrapper units DbiTypes,
> DbiErrs, and DbiProcs must be included in the Uses section of the unit
> that is to make a call to a BDE function.
> Example code follows...
> unit Pack_1;
> interface
> uses
> SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
> Forms, Dialogs, StdCtrls, Grids, DBGrids, DB, DBTables,
> DbiTypes, DbiProcs, DbiErrs;
> type
> TForm1 = class(TForm)
> Table1: TTable;
> DataSource1: TDataSource;
> DBGrid1: TDBGrid;
> Button1: TButton;
> procedure Button1Click(Sender: TObject);
> procedure FormShow(Sender: TObject);
> procedure FormClose(Sender: TObject; var Action: TCloseAction);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
> var
> Form1: TForm1;
> implementation
> {$R *.DFM}
> procedure TForm1.Button1Click(Sender: TObject);
> var
> Error: DbiResult;
> ErrorMsg: String;
> Special: DBIMSG;
> begin
> table1.Active := False;
> try
> Table1.Exclusive := True;
> Table1.Active := True;
> Error := DbiPackTable(Table1.DBHandle, Table1.Handle,
> nil, szdBASE, True);
> Table1.Active := False;
> Table1.Exclusive := False;
> finally
> Table1.Active := True;
> end;
> case Error of
> DBIERR_NONE:
> ErrorMsg := 'Successful';
> DBIERR_INVALIDPARAM:
> ErrorMsg := 'The specified table name or the pointer to the table ' +
> 'name is NULL';
> DBIERR_INVALIDHNDL:
> ErrorMsg := 'The specified database handle or cursor handle is ' +
> 'invalid or NULL';
> DBIERR_NOSUCHTABLE:
> ErrorMsg := 'Table name does not exist';
> DBIERR_UNKNOWNTBLTYPE:
> ErrorMsg := 'Table type is unknown';
> DBIERR_NEEDEXCLACCESS:
> ErrorMsg := 'The table is not open in exclusive mode';
> else
> DbiGetErrorString(Error, Special);
> ErrorMsg := '[' + IntToStr(Error) + ']: ' + Special;
> end;
> MessageDlg(ErrorMsg, mtWarning, [mbOk], 0);
> end;
> procedure TForm1.FormShow(Sender: TObject);
> begin
> Table1.Active := True;
> end;
> procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
> begin
> Table1.Active := False;
> end;
> end.