Browse Source

+ fcl-db/dbase: implemented FindFirst,FindNext,FindPrior,FindLast and associated tests

git-svn-id: trunk@24107 -
reiniero 12 years ago
parent
commit
2569f52b73

+ 31 - 3
packages/fcl-db/src/dbase/dbf.pas

@@ -260,7 +260,11 @@ type
     procedure SetFieldData(Field: TField; Buffer: Pointer);
       {$ifdef SUPPORT_OVERLOAD} overload; {$endif} override; {virtual abstract}
 
-    { virtual methods (mostly optionnal) }
+    { virtual methods (mostly optional) }
+    function  FindFirst: Boolean; override;
+    function  FindLast: Boolean; override;
+    function  FindNext: Boolean; override;
+    function  FindPrior: Boolean; override;
     function  GetDataSource: TDataSource; {$ifndef VER1_0}override;{$endif}
     function  GetRecordCount: Integer; override; {virtual}
     function  GetRecNo: Integer; override; {virtual}
@@ -753,6 +757,30 @@ begin
   SetFieldData(Field, Buffer, true);
 end;
 
+function TDbf.FindFirst: Boolean;
+begin
+  // Use inherited function; if failed use FindRecord
+  Result:=inherited FindFirst or FindRecord(True, True);
+end;
+
+function TDbf.FindLast: Boolean;
+begin
+  // Use inherited function; if failed use FindRecord
+  Result:=inherited FindLast or FindRecord(True, False);
+end;
+
+function TDbf.FindNext: Boolean;
+begin
+  // Use inherited function; if failed use FindRecord
+  Result:=inherited FindNext or FindRecord(False, True);
+end;
+
+function TDbf.FindPrior: Boolean;
+begin
+  // Use inherited function; if failed use FindRecord
+  Result:=inherited FindPrior or FindRecord(False, False);
+end;
+
 procedure TDbf.SetFieldData(Field: TField; Buffer: Pointer; NativeFormat: Boolean); {overload; override;}
 {$else}
 const
@@ -1299,7 +1327,7 @@ begin
     Result := 0;
 end;
 
-function TDbf.GetLanguageStr: String;
+function TDbf.GetLanguageStr: string;
 begin
   if FDbfFile <> nil then
     Result := FDbfFile.LanguageStr;
@@ -2293,7 +2321,7 @@ begin
   end;
 end;
 
-procedure TDbf.SetTableName(const s: string);
+procedure TDbf.SetTableName(const S: string);
 var
   lPath: string;
 begin

+ 1 - 0
packages/fcl-db/src/dbase/history.txt

@@ -32,6 +32,7 @@ BUGS & WARNINGS
 
 
 FreePascal trunk:
+- implemented FindFirst,FindNext,FindPrior,FindLast
 - compile fix for FPC 2.6.2 (r24069), possibly useful for Delphi
 
 ------------------------

+ 3 - 1
packages/fcl-db/src/dbase/readme.txt

@@ -16,4 +16,6 @@ License is LGPL (Library General Public License); see COPYING.LIB for details.
 
 Development notes/additions to end user documentation
 
-property RecNo: approximate record number. Does not take deleted records into account. Used mainly in grids.
+property RecNo: approximate record number. Does not take deleted records into account. Used mainly in grids.
+
+