DBF - pack

Top  Previous  Next

Para fazer um Pack em DBF:

 

function PackTable(const Alias, NomeTabela : String; ArquivoIndice : String = ''; Indice : String = '') : Boolean;

var

  TempTable : TTable;

begin

  TempTable := TTable.Create(nil);

  with TempTable do

  begin

    TableName    := NomeTabela;

    if ArquivoIndice <> '' then IndexFiles.Add(ArquivoIndice);

    if Indice <> '' then IndexName := Indice;

    DatabaseName := Alias;

    Exclusive    := True;

    DisableControls;

    try

      Open;

    except

      TempTable.Free;

      Result := False;

      Exit;

    end;

    Result := DbiPackTable(DBHandle, Handle, nil, nil, True) = DBIERR_NONE;

  end;

  TempTable.Free;

end;