mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-01 09:46:46 +02:00
fcl-db: examples: dbftool: cosmetic: code cleanup
git-svn-id: trunk@27027 -
This commit is contained in:
parent
7eace968e7
commit
c2902b3aa6
@ -261,21 +261,30 @@ type
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure PrintRecord(DBf: TDBf; RecordNumber: integer);
|
procedure PrintRecords(DBf: TDBf);
|
||||||
// Prints contents of a record to screen
|
// Prints contents of available records to screen
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
|
RecordCount: integer;
|
||||||
begin
|
begin
|
||||||
writeln('Record ' + IntToStr(RecordNumber));
|
Dbf.First;
|
||||||
for i := 0 to DBf.Fields.Count - 1 do
|
RecordCount:=0;
|
||||||
|
while not (Dbf.EOF) do
|
||||||
begin
|
begin
|
||||||
if DBF.fields[i].IsNull then
|
RecordCount := RecordCount + 1;
|
||||||
writeln('Field ', DBf.Fields[i].FieldName, ' is ***NULL***')
|
writeln('Record ' + IntToStr(RecordCount));
|
||||||
else
|
for i := 0 to DBf.Fields.Count - 1 do
|
||||||
if DBF.Fields[i].DataType in [ftVarBytes, ftBytes] then
|
begin
|
||||||
writeln('Field ', DBF.Fields[i].FieldName, ' has value: binary ' + BinFieldToHex(DBF.Fields[i]))
|
if DBF.fields[i].IsNull then
|
||||||
else
|
writeln('Field ', DBf.Fields[i].FieldName, ' is ***NULL***')
|
||||||
writeln('Field ', DBf.Fields[i].FieldName, ' has value: ' + DBf.fields[i].AsString);
|
else
|
||||||
|
if DBF.Fields[i].DataType in [ftVarBytes, ftBytes] then
|
||||||
|
writeln('Field ', DBF.Fields[i].FieldName, ' has value: binary ' + BinFieldToHex(DBF.Fields[i]))
|
||||||
|
else
|
||||||
|
writeln('Field ', DBf.Fields[i].FieldName, ' has value: ' + DBf.fields[i].AsString);
|
||||||
|
end;
|
||||||
|
DBF.Next;
|
||||||
|
writeln('');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -415,8 +424,7 @@ type
|
|||||||
ErrorMsg: string;
|
ErrorMsg: string;
|
||||||
FileNo: integer;
|
FileNo: integer;
|
||||||
MyDbf: TDbf;
|
MyDbf: TDbf;
|
||||||
RecCount: integer;
|
TableLevel: integer;
|
||||||
TableLevel: integer; //todo: use it
|
|
||||||
begin
|
begin
|
||||||
// quick check parameters
|
// quick check parameters
|
||||||
ErrorMsg := CheckOptions('h', 'createdemo exportformat: help tablelevel:');
|
ErrorMsg := CheckOptions('h', 'createdemo exportformat: help tablelevel:');
|
||||||
@ -485,14 +493,7 @@ type
|
|||||||
writeln('Database tablelevel: ' + IntToStr(MyDbf.TableLevel));
|
writeln('Database tablelevel: ' + IntToStr(MyDbf.TableLevel));
|
||||||
writeln('Database codepage: ' + IntToStr(MyDBF.CodePage));
|
writeln('Database codepage: ' + IntToStr(MyDBF.CodePage));
|
||||||
|
|
||||||
RecCount := 1;
|
PrintRecords(MyDBF);
|
||||||
while not (MyDbf.EOF) do
|
|
||||||
begin
|
|
||||||
PrintRecord(MyDBF, RecCount);
|
|
||||||
MyDBF.Next;
|
|
||||||
RecCount := RecCount + 1;
|
|
||||||
writeln('');
|
|
||||||
end;
|
|
||||||
|
|
||||||
if HasOption('exportformat') then
|
if HasOption('exportformat') then
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user