summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/fcl-db/src/dbase/testdbf.pp
blob: 61e100266f9249d9d0b915e3cb40530700f09659 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
program dumpdb;

{$i+}

uses DB,Dbf,SysUtils;

Procedure DumpTable (Const TN,FN : String);

Var
  I,Count : longint;
  F : Text;
  Buf : Array[1..1024*4] of byte;

begin
  Assign(F,FN);
  Rewrite(F);
//  SetTextBuf(F,Buf);
  With TDBF.Create(Nil) do
    begin
    TableName:=TN;
    Open;
    While not EOF do
      begin
      Inc(Count);
      For I:=0 to FieldCount-1 do
        With Fields[i] do
          Writeln(F,FieldName:20,' : ',AsString);
      Writeln(F,StringOfChar('=',72));
      Next;
      end;
    end;
  Writeln(F,'Dumped total of ',Count,' records.');
  Close(F);
end;

Var i : longint;

begin
  If ParamCount<2 then
    begin
    Writeln('Usage: dumpdb tablename filename');
    Halt(1);
    end;
  DumpTable(Paramstr(1),Paramstr(2));
end.