 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Bruno Guest
|
Posted: Thu May 13, 2004 5:33 pm Post subject: Detach a dbf file |
|
|
Hi,
I want a software that detach the dbf file without an index.
How could I do it on delphi?
Bruno
---
"Um gênio é uma pessoa de talento que faz toda a lição de casa"
(Thomas A. Edison)
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.683 / Virus Database: 445 - Release Date: 12/05/2004
|
|
| Back to top |
|
 |
Bruno Guest
|
Posted: Thu May 13, 2004 7:51 pm Post subject: Re: Detach a dbf file |
|
|
i´ve got
tks
---
"Um gênio é uma pessoa de talento que faz toda a lição de casa"
(Thomas A. Edison)
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.684 / Virus Database: 446 - Release Date: 13/05/2004
|
|
| Back to top |
|
 |
Bruno Guest
|
Posted: Fri May 14, 2004 1:21 pm Post subject: Re: Detach a dbf file |
|
|
unit dBaseIV;
{$D-}
interface
procedure DeletarIndice(const dBASE_File_Name: string);
implementation
uses SysUtils, Classes;
{**************************************************************************
* The data file header structure for dBASE IV 2.0 table file.
***************************************************************************
File Structure:
===============
Byte Contents Meaning
------- ---------- -------------------------------------------------
0 1 byte Valid dBASE IV file; bits 0-2 indicate version
number, bit 3 the presence of a dBASE IV memo
file, bits 4-6 the presence of an SQL table, bit
7 the presence of any memo file (either dBASE III
PLUS or dBASE IV).
1-3 3 bytes Date of last update; formattted as YYMMDD.
4-7 32-bit number Number of records in the file.
8-9 16-bit number Number of bytes in the header.
10-11 16-bit number Number of bytes in the record.
12-13 2 bytes Reserved; fill with 0.
14 1 byte Flag indicating incomplete transaction.
15 1 byte Encryption flag.
16-27 12 bytes Reserved for dBASE IV in a multi-user environment.
28 1 bytes Production MDX file flag; 01H if there is an MDX,
00H if not.
29 1 byte Language driver ID.
30-31 2 bytes Reserved; fill with 0.
32-n* 32 bytes each Field descriptor array (see below).
n + 1 1 byte 0DH as the field terminator.
* n is the last byte in the field descriptor array. The size of the array
depends on the number of fields in the database file.
}
type
// Não é todo o cabeçalho de um arquivo dBASE, mas apenas a parte que nos
interessa.
TDBF = packed record
Flag: Byte; // Versão, Memo IV, SQL Table, etc.
YYMMDD: array[1..3] of Byte; // Data da última atualização, YYMMDD.
RecordCount: LongInt; // Número de registros no arquivo.
HeaderSize: Word; // Número de bytes no cabeçalho.
RecordSize: Word; // Número de bytes no registro.
Reserved00: array[1..2] of Byte; // Reservado; preenchido com 0.
TransactionOK: ByteBool; // Flag indicando transação
incompleta.
EncryptionFlag: Byte;
MultiUser: array[1..12] of Byte; // Reservado pelo dBASE IV em ambient
multiusuário.
ProductionMDX: ByteBool; // True se Production MDX existe.
end;
procedure DeletarIndice(const dBASE_File_Name: string);
var
dBASE_File: file;
Header: TDBF;
begin
// Mata o arquivo de índices, se existir.
DeleteFile(ChangeFileExt(dBASE_File_Name, '.MDX'));
// E agora, marca que não existe.
if FileExists(dBASE_File_Name) then begin
AssignFile(dBASE_File, dBASE_File_Name);
Reset(dBASE_File, 1);
try
BlockRead(dBASE_File, Header, SizeOf(Header));
Header.ProductionMDX := False; // Não temos mais Production
Index (arquivo.MDX).
Seek(dBASE_File, 0);
BlockWrite(dBASE_File, Header, SizeOf(Header));
finally
CloseFile(dBASE_File);
end;
end;
end;
end.
---
"Um gênio é uma pessoa de talento que faz toda a lição de casa"
(Thomas A. Edison)
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.684 / Virus Database: 446 - Release Date: 13/05/2004
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|