Browse Source

* move fcl-db/src/*.{inc,pp,pas} to fcl-db/base to be able to specify
dependendies of other subdirectories (such as export and datadict) on it
* added .NOTPARALLEL to the export and datadict directories

git-svn-id: trunk@9228 -

Jonas Maebe 18 years ago
parent
commit
44e7fffed5

+ 12 - 12
.gitattributes

@@ -4090,9 +4090,18 @@ packages/fcl-db/Makefile svneol=native#text/plain
 packages/fcl-db/Makefile.fpc svneol=native#text/plain
 packages/fcl-db/src/Dataset.txt svneol=native#text/plain
 packages/fcl-db/src/README -text
-packages/fcl-db/src/bufdataset.pas svneol=native#text/plain
-packages/fcl-db/src/bufdataset_parser.pp svneol=native#text/plain
-packages/fcl-db/src/database.inc svneol=native#text/plain
+packages/fcl-db/src/base/bufdataset.pas svneol=native#text/plain
+packages/fcl-db/src/base/bufdataset_parser.pp svneol=native#text/plain
+packages/fcl-db/src/base/database.inc svneol=native#text/plain
+packages/fcl-db/src/base/dataset.inc svneol=native#text/plain
+packages/fcl-db/src/base/datasource.inc svneol=native#text/plain
+packages/fcl-db/src/base/db.pas svneol=native#text/plain
+packages/fcl-db/src/base/dbconst.pas svneol=native#text/plain
+packages/fcl-db/src/base/dbwhtml.pp svneol=native#text/plain
+packages/fcl-db/src/base/dsparams.inc svneol=native#text/plain
+packages/fcl-db/src/base/fields.inc svneol=native#text/plain
+packages/fcl-db/src/base/fpmake.inc svneol=native#text/plain
+packages/fcl-db/src/base/fpmake.pp svneol=native#text/plain
 packages/fcl-db/src/datadict/Makefile svneol=native#text/plain
 packages/fcl-db/src/datadict/Makefile.fpc svneol=native#text/plain
 packages/fcl-db/src/datadict/buildd.lpi svneol=native#text/plain
@@ -4109,9 +4118,6 @@ packages/fcl-db/src/datadict/fpddpq.pp svneol=native#text/plain
 packages/fcl-db/src/datadict/fpddregstd.pp svneol=native#text/plain
 packages/fcl-db/src/datadict/fpddsqldb.pp svneol=native#text/plain
 packages/fcl-db/src/datadict/fpddsqlite3.pp svneol=native#text/plain
-packages/fcl-db/src/dataset.inc svneol=native#text/plain
-packages/fcl-db/src/datasource.inc svneol=native#text/plain
-packages/fcl-db/src/db.pas svneol=native#text/plain
 packages/fcl-db/src/dbase/Makefile svneol=native#text/plain
 packages/fcl-db/src/dbase/Makefile.fpc svneol=native#text/plain
 packages/fcl-db/src/dbase/dbf.pas svneol=native#text/plain
@@ -4152,9 +4158,6 @@ packages/fcl-db/src/dbase/package.txt svneol=native#text/plain
 packages/fcl-db/src/dbase/readme.txt svneol=native#text/plain
 packages/fcl-db/src/dbase/tdbf_l.pas svneol=native#text/plain
 packages/fcl-db/src/dbase/testdbf.pp svneol=native#text/plain
-packages/fcl-db/src/dbconst.pas svneol=native#text/plain
-packages/fcl-db/src/dbwhtml.pp svneol=native#text/plain
-packages/fcl-db/src/dsparams.inc svneol=native#text/plain
 packages/fcl-db/src/export/Makefile svneol=native#text/plain
 packages/fcl-db/src/export/Makefile.fpc svneol=native#text/plain
 packages/fcl-db/src/export/fpcsvexport.pp svneol=native#text/plain
@@ -4167,9 +4170,6 @@ packages/fcl-db/src/export/fpsimplexmlexport.pp svneol=native#text/plain
 packages/fcl-db/src/export/fpsqlexport.pp svneol=native#text/plain
 packages/fcl-db/src/export/fpstdexports.pp svneol=native#text/plain
 packages/fcl-db/src/export/fptexexport.pp svneol=native#text/plain
-packages/fcl-db/src/fields.inc svneol=native#text/plain
-packages/fcl-db/src/fpmake.inc svneol=native#text/plain
-packages/fcl-db/src/fpmake.pp svneol=native#text/plain
 packages/fcl-db/src/memds/Makefile svneol=native#text/plain
 packages/fcl-db/src/memds/Makefile.fpc svneol=native#text/plain
 packages/fcl-db/src/memds/README -text

File diff suppressed because it is too large
+ 108 - 744
packages/fcl-db/Makefile


+ 25 - 11
packages/fcl-db/Makefile.fpc

@@ -7,26 +7,22 @@ name=fcl-db
 version=2.0.0
 
 [target]
-dirs=src/sdf src/memds src/sqldb 
-dirs_linux=src/dbase src/sqlite src/export src/datadict
-dirs_freebsd=src/dbase src/sqlite src/export src/datadict
-dirs_darwin=src/sqlite src/export src/datadict
-dirs_solaris=src/sqlite src/export src/datadict
-dirs_netbsd=src/sqlite src/export src/datadict
-dirs_openbsd=src/sqlite src/export src/datadict
+dirs=src/sdf src/memds src/sqldb src/base
+dirs_linux=src/sqlite src/export src/datadict
+dirs_freebsd=src/sqlite
+dirs_darwin=src/sqlite
+dirs_solaris=src/sqlite
+dirs_netbsd=src/sqlite
+dirs_openbsd=src/sqlite
 dirs_win32=src/dbase src/sqlite src/export src/datadict
 dirs_win64=src/dbase src/export src/datadict
 dirs_wince=src/dbase src/sqlite src/export src/datadict
-units=dbconst db dbwhtml bufdataset_parser bufdataset 
-rsts=dbwhtml dbconst
 
 [require]
 packages=fcl-base
 
 [compiler]
 options=-S2h
-unitdir=src/dbase
-sourcedir=src
 
 [install]
 fpcpackage=y
@@ -37,3 +33,21 @@ fpcdir=../..
 
 [rules]
 .NOTPARALLEL:
+
+src/export_all: src/base_all src/dbase_all
+src/export_debug: src/base_debug src/dbase_debug
+src/export_smart: src/base_smart src/dbase_smart
+src/export_release: src/base_release src/dbase_release
+src/export_shared: src/base_shared src/dbase_shared
+
+src/sdf_all: src/base_all
+src/sdf_debug: src/base_debug
+src/sdf_smart: src/base_smart
+src/sdf_release: src/base_release
+src/sdf_shared: src/base_shared
+
+src/dbase_all: src/base_all
+src/dbase_debug: src/base_debug
+src/dbase_smart: src/base_smart
+src/dbase_release: src/base_release
+src/dbase_shared: src/base_shared

+ 0 - 0
packages/fcl-db/src/bufdataset.pas → packages/fcl-db/src/base/bufdataset.pas


+ 0 - 0
packages/fcl-db/src/bufdataset_parser.pp → packages/fcl-db/src/base/bufdataset_parser.pp


+ 0 - 0
packages/fcl-db/src/database.inc → packages/fcl-db/src/base/database.inc


+ 0 - 0
packages/fcl-db/src/db.pas → packages/fcl-db/src/base/db.pas


+ 0 - 0
packages/fcl-db/src/dbconst.pas → packages/fcl-db/src/base/dbconst.pas


+ 0 - 0
packages/fcl-db/src/dbwhtml.pp → packages/fcl-db/src/base/dbwhtml.pp


+ 0 - 0
packages/fcl-db/src/dsparams.inc → packages/fcl-db/src/base/dsparams.inc


+ 0 - 0
packages/fcl-db/src/fpmake.inc → packages/fcl-db/src/base/fpmake.inc


+ 0 - 0
packages/fcl-db/src/fpmake.pp → packages/fcl-db/src/base/fpmake.pp


+ 110 - 2
packages/fcl-db/src/datadict/Makefile

@@ -1,5 +1,5 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/11/10]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/11/08]
 #
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
@@ -1467,165 +1467,220 @@ else
 TAROPT=vz
 TAREXT=.tar.gz
 endif
-override REQUIRE_PACKAGES=rtl 
+override REQUIRE_PACKAGES=rtl fcl-base
 ifeq ($(FULL_TARGET),i386-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_WINUNITS=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_WINUNITS=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifdef REQUIRE_PACKAGES_RTL
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
@@ -1653,6 +1708,58 @@ ifdef UNITDIR_RTL
 override COMPILER_UNITDIR+=$(UNITDIR_RTL)
 endif
 endif
+ifdef REQUIRE_PACKAGES_FCL-BASE
+PACKAGEDIR_FCL-BASE:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /fcl-base/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_FCL-BASE),)
+ifneq ($(wildcard $(PACKAGEDIR_FCL-BASE)/units/$(TARGETSUFFIX)),)
+UNITDIR_FCL-BASE=$(PACKAGEDIR_FCL-BASE)/units/$(TARGETSUFFIX)
+else
+UNITDIR_FCL-BASE=$(PACKAGEDIR_FCL-BASE)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_FCL-BASE)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_FCL-BASE) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_FCL-BASE)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_FCL-BASE=
+UNITDIR_FCL-BASE:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /fcl-base/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_FCL-BASE),)
+UNITDIR_FCL-BASE:=$(firstword $(UNITDIR_FCL-BASE))
+else
+UNITDIR_FCL-BASE=
+endif
+endif
+ifdef UNITDIR_FCL-BASE
+override COMPILER_UNITDIR+=$(UNITDIR_FCL-BASE)
+endif
+endif
+ifdef REQUIRE_PACKAGES_WINUNITS
+PACKAGEDIR_WINUNITS:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /winunits/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_WINUNITS),)
+ifneq ($(wildcard $(PACKAGEDIR_WINUNITS)/units/$(TARGETSUFFIX)),)
+UNITDIR_WINUNITS=$(PACKAGEDIR_WINUNITS)/units/$(TARGETSUFFIX)
+else
+UNITDIR_WINUNITS=$(PACKAGEDIR_WINUNITS)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_WINUNITS)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_WINUNITS) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_WINUNITS)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_WINUNITS=
+UNITDIR_WINUNITS:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /winunits/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_WINUNITS),)
+UNITDIR_WINUNITS:=$(firstword $(UNITDIR_WINUNITS))
+else
+UNITDIR_WINUNITS=
+endif
+endif
+ifdef UNITDIR_WINUNITS
+override COMPILER_UNITDIR+=$(UNITDIR_WINUNITS)
+endif
+endif
 ifndef NOCPUDEF
 override FPCOPTDEF=$(CPU_TARGET)
 endif
@@ -2160,3 +2267,4 @@ makefiles: fpc_makefiles
 ifneq ($(wildcard fpcmake.loc),)
 include fpcmake.loc
 endif
+.NOTPARALLEL:

+ 4 - 0
packages/fcl-db/src/datadict/Makefile.fpc

@@ -5,6 +5,9 @@
 [package]
 main=fcl-db
 
+[require]
+packages=fcl-base
+
 [target]
 units=fpdatadict fpdddbf fpddsqldb
 units_linux=fpddfb fpddmysql40 fpddmysql41 fpddmysql50 fpddodbc fpddpq fpddoracle fpddsqlite3 fpddregstd
@@ -35,3 +38,4 @@ fpcpackage=y
 fpcdir=../../../..
 
 [rules]
+.NOTPARALLEL:

+ 0 - 2178
packages/fcl-db/src/dataset.inc

@@ -1,2178 +0,0 @@
-{
-    This file is part of the Free Pascal run time library.
-    Copyright (c) 1999-2000 by Michael Van Canneyt, member of the
-    Free Pascal development team
-
-    Dataset implementation
-
-    See the file COPYING.FPC, included in this distribution,
-    for details about the copyright.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- **********************************************************************}
-{ ---------------------------------------------------------------------
-    TDataSet
-  ---------------------------------------------------------------------}
-
-Const
-  DefaultBufferCount = 10;
-
-constructor TDataSet.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  FFieldDefs:=TFieldDefs.Create(Self);
-  FFieldList:=TFields.Create(Self);
-  FDataSources:=TList.Create;
-  
-// FBuffer must be allocated on create, to make Activebuffer return nil
-  ReAllocMem(FBuffers,SizeOf(PChar));
-//  pointer(FBuffers^) := nil;
-  FBuffers[0] := nil;
-  FActiveRecord := 0;
-  FBufferCount := 0;
-  FEOF := True;
-  FBOF := True;
-  FIsUniDirectional := False;
-end;
-
-
-
-destructor TDataSet.Destroy;
-
-var
-  i: Integer;
-
-begin
-  Active:=False;
-  FFieldDefs.Free;
-  FFieldList.Free;
-  With FDatasources do
-    begin
-    While Count>0 do
-      TDatasource(Items[Count - 1]).DataSet:=Nil;
-    Free;
-    end;
-  for i := 0 to FBufferCount do
-    FreeRecordBuffer(FBuffers[i]);
-  FreeMem(FBuffers);
-  Inherited Destroy;
-end;
-
-// This procedure must be called when the first record is made/read
-Procedure TDataset.ActivateBuffers;
-
-begin
-  FBOF:=False;
-  FEOF:=False;
-  FActiveRecord:=0;
-end;
-
-Procedure TDataset.UpdateFieldDefs;
-
-begin
-  //!! To be implemented
-end;
-
-Procedure TDataset.BindFields(Binding: Boolean);
-
-var i, FieldIndex: Integer;
-    FieldDef: TFieldDef;
-begin
-  {
-     Here some magic will be needed later; for now just simply set
-     Just set fieldno from listindex...
-     Later we should take it from the fielddefs.
-     // ATM Set by CreateField ...
-  For I:=0 to FFieldList.Count-1 do
-    FFieldList[i].FFieldNo:=I;
-  }
-  FCalcFieldsSize := 0;
-  FBlobFieldCount := 0;
-  for i := 0 to Fields.Count - 1 do
-    with Fields[i] do begin
-      if Binding then begin
-        if FieldKind in [fkCalculated, fkLookup] then begin
-          FFieldNo := -1;
-          FOffset := FCalcFieldsSize;
-          Inc(FCalcFieldsSize, DataSize + 1);
-          if FieldKind in [fkLookup] then begin
-            if ((FLookupDataSet = nil) or (FLookupKeyFields = '') or
-               (FLookupResultField = '') or (FKeyFields = '')) then
-              DatabaseErrorFmt(SLookupInfoError, [DisplayName]);
-            FFields.CheckFieldNames(FKeyFields);
-            FLookupDataSet.Fields.CheckFieldNames(FLookupKeyFields);
-            FLookupDataSet.FieldByName(FLookupResultField);
-            if FLookupCache then RefreshLookupList;
-          end
-        end else begin
-          FieldDef := nil;
-          FieldIndex := FieldDefs.IndexOf(Fields[i].FieldName);
-          if FieldIndex <> -1 then begin
-            FieldDef := FieldDefs[FieldIndex];
-            FFieldNo := FieldDef.FieldNo;
-            if IsBlob then begin
-              FSize := FieldDef.Size;
-              FOffset := FBlobFieldCount;
-              Inc(FBlobFieldCount);
-            end;
-          end else FFieldNo := FieldIndex;
-        end;
-      end else FFieldNo := 0;;
-    end;
-end;
-
-Function TDataset.BookmarkAvailable: Boolean;
-
-Const BookmarkStates = [dsBrowse,dsEdit,dsInsert];
-
-begin
-  Result:=(Not IsEmpty) and  not FIsUniDirectional and (State in BookmarkStates)
-          and (getBookMarkFlag(ActiveBuffer)=bfCurrent);
-end;
-
-Procedure TDataset.CalculateFields(Buffer: PChar);
-
-var
-  I: Integer;
-begin
-  FCalcBuffer := Buffer;
-  if (State <> dsInternalCalc) and (FIsUniDirectional = False) then
-  begin
-    ClearCalcFields(CalcBuffer);
-    for I := 0 to Fields.Count - 1 do
-      with Fields[I] do
-        if FieldKind = fkLookup then CalcLookupValue;
-  end;
-  DoOnCalcFields;
-end;
-
-Procedure TDataset.CheckActive;
-
-begin
-  If Not Active then
-    DataBaseError(SInactiveDataset);
-end;
-
-Procedure TDataset.CheckInactive;
-
-begin
-  If Active then
-    DataBaseError(SActiveDataset);
-end;
-
-Procedure TDataset.ClearBuffers;
-
-begin
-  FRecordCount:=0;
-  FactiveRecord:=0;
-  FCurrentRecord:=-1;
-  FBOF:=True;
-  FEOF:=True;
-end;
-
-Procedure TDataset.ClearCalcFields(Buffer: PChar);
-
-begin
-  if FCalcFieldsSize > 0 then
-    FillByte((Buffer+RecordSize)^,FCalcFieldsSize,0);
-end;
-
-Procedure TDataset.CloseBlob(Field: TField);
-
-begin
-  //!! To be implemented
-end;
-
-Procedure TDataset.CloseCursor;
-
-begin
-  FreeFieldBuffers;
-  ClearBuffers;
-  SetBufListSize(0);
-  InternalClose;
-  FInternalOpenComplete := False;
-end;
-
-Procedure TDataset.CreateFields;
-
-Var I : longint;
-
-begin
-{$ifdef DSDebug}
-  Writeln ('Creating fields');
-  Writeln ('Count : ',fielddefs.Count);
-  For I:=0 to FieldDefs.Count-1 do
-    Writeln('Def ',I,' : ',Fielddefs.items[i].Name,'(',Fielddefs.items[i].FieldNo,')');
-{$endif}
-  For I:=0 to fielddefs.Count-1 do
-    With Fielddefs.Items[I] do
-      If DataType<>ftUnknown then
-        begin
-        {$ifdef DSDebug}
-        Writeln('About to create field',FieldDefs.Items[i].Name);
-        {$endif}
-        CreateField(self);
-        end;
-end;
-
-Procedure TDataset.DataEvent(Event: TDataEvent; Info: Ptrint);
-
-Var
-  i : longint;
-
-begin
-  // Do some bookkeeping;
-  case Event of
-    deFieldChange: begin
-        if TField(Info).FieldKind in [fkData,fkInternalCalc] then
-          SetModified(True);
-        if State <> dsSetKey then begin
-          if FInternalCalcFields and (TField(Info).FieldKind = fkData) then
-              RefreshInternalCalcFields(ActiveBuffer)
-          else if (FCalcFieldsSize <> 0) and FAutoCalcFields and
-            (TField(Info).FieldKind = fkData) then
-            CalculateFields(ActiveBuffer);
-          TField(Info).Change;
-        end;
-    end;
-    deDataSetChange, deDataSetScroll:
-      if State <> dsInsert then UpdateCursorPos;
-  end;
-  // Distribute event to datasets;
-  if FDisableControlsCount = 0 then
-    for I := 0 to FDataSources.Count - 1 do
-      TDataSource(FDataSources[I]).ProcessEvent(Event, Info);
-end;
-
-Procedure TDataset.DestroyFields;
-
-begin
-  FFieldList.Clear;
-end;
-
-Procedure TDataset.DoAfterCancel;
-
-begin
- If assigned(FAfterCancel) then
-   FAfterCancel(Self);
-end;
-
-Procedure TDataset.DoAfterClose;
-
-begin
- If assigned(FAfterClose) then
-   FAfterClose(Self);
-end;
-
-Procedure TDataset.DoAfterDelete;
-
-begin
- If assigned(FAfterDelete) then
-   FAfterDelete(Self);
-end;
-
-Procedure TDataset.DoAfterEdit;
-
-begin
- If assigned(FAfterEdit) then
-   FAfterEdit(Self);
-end;
-
-Procedure TDataset.DoAfterInsert;
-
-begin
- If assigned(FAfterInsert) then
-   FAfterInsert(Self);
-end;
-
-Procedure TDataset.DoAfterOpen;
-
-begin
- If assigned(FAfterOpen) then
-   FAfterOpen(Self);
-end;
-
-Procedure TDataset.DoAfterPost;
-
-begin
- If assigned(FAfterPost) then
-   FAfterPost(Self);
-end;
-
-Procedure TDataset.DoAfterScroll;
-
-begin
- If assigned(FAfterScroll) then
-   FAfterScroll(Self);
-end;
-
-Procedure TDataset.DoAfterRefresh;
-
-begin
- If assigned(FAfterRefresh) then
-   FAfterRefresh(Self);
-end;
-
-Procedure TDataset.DoBeforeCancel;
-
-begin
- If assigned(FBeforeCancel) then
-   FBeforeCancel(Self);
-end;
-
-Procedure TDataset.DoBeforeClose;
-
-begin
- If assigned(FBeforeClose) then
-   FBeforeClose(Self);
-end;
-
-Procedure TDataset.DoBeforeDelete;
-
-begin
- If assigned(FBeforeDelete) then
-   FBeforeDelete(Self);
-end;
-
-Procedure TDataset.DoBeforeEdit;
-
-begin
- If assigned(FBeforeEdit) then
-   FBeforeEdit(Self);
-end;
-
-Procedure TDataset.DoBeforeInsert;
-
-begin
- If assigned(FBeforeInsert) then
-   FBeforeInsert(Self);
-end;
-
-Procedure TDataset.DoBeforeOpen;
-
-begin
- If assigned(FBeforeOpen) then
-   FBeforeOpen(Self);
-end;
-
-Procedure TDataset.DoBeforePost;
-
-begin
- If assigned(FBeforePost) then
-   FBeforePost(Self);
-end;
-
-Procedure TDataset.DoBeforeScroll;
-
-begin
- If assigned(FBeforeScroll) then
-   FBeforeScroll(Self);
-end;
-
-Procedure TDataset.DoBeforeRefresh;
-
-begin
- If assigned(FBeforeRefresh) then
-   FBeforeRefresh(Self);
-end;
-
-Procedure TDataset.DoInternalOpen;
-
-begin
-  FDefaultFields:=FieldCount=0;
-  InternalOpen;
-  FInternalOpenComplete := True;
-{$ifdef dsdebug}
-  Writeln ('Calling internal open');
-{$endif}
-  FBOF:=True;
-{$ifdef dsdebug}
-  Writeln ('Calling RecalcBufListSize');
-{$endif}
-  FRecordcount := 0;
-  RecalcBufListSize;
-  FEOF := (FRecordcount = 0);
-end;
-
-Procedure TDataset.DoOnCalcFields;
-
-begin
- If assigned(FOnCalcfields) then
-   FOnCalcFields(Self);
-end;
-
-Procedure TDataset.DoOnNewRecord;
-
-begin
- If assigned(FOnNewRecord) then
-   FOnNewRecord(Self);
-end;
-
-Function TDataset.FieldByNumber(FieldNo: Longint): TField;
-
-begin
-  Result:=FFieldList.FieldByNumber(FieldNo);
-end;
-
-Function TDataset.FindRecord(Restart, GoForward: Boolean): Boolean;
-
-begin
-  //!! To be implemented
-end;
-
-Procedure TDataset.FreeFieldBuffers;
-
-Var I : longint;
-
-begin
-  For I:=0 to FFieldList.Count-1 do
-    FFieldList[i].FreeBuffers;
-end;
-
-Function TDataset.GetBookmarkStr: TBookmarkStr;
-
-begin
-  Result:='';
-  If BookMarkAvailable then
-    begin
-    SetLength(Result,FBookMarkSize);
-    GetBookMarkData(ActiveBuffer,Pointer(Result));
-    end
-end;
-
-Function TDataset.GetBuffer (Index : longint) : Pchar;
-
-begin
-  Result:=FBuffers[Index];
-end;
-
-Procedure TDataset.GetCalcFields(Buffer: PChar);
-
-var
-  dss: TDataSetState;
-begin
-  if (FCalcFieldsSize > 0) or FInternalCalcFields then
-  begin
-    dss := FState;
-    FState := dsCalcFields;
-    try
-      CalculateFields(Buffer);
-    finally
-      FState := dss;
-    end;
-  end;
-end;
-
-Function TDataset.GetCanModify: Boolean;
-
-begin
-  Result:= not FIsUnidirectional;
-end;
-
-Procedure TDataset.GetChildren(Proc: TGetChildProc; Root: TComponent);
-
-var
- I: Integer;
- Field: TField;
-
-begin
- for I := 0 to Fields.Count - 1 do begin
-   Field := Fields[I];
-   if (Field.Owner = Root) then
-     Proc(Field);
- end;
-end;
-
-Function TDataset.GetDataSource: TDataSource;
-begin
-  Result:=nil;
-end;
-
-function TDataSet.GetFieldData(Field: TField; Buffer: Pointer): Boolean;
-
-begin
-  Result := False;
-end;
-
-procedure TDataSet.DataConvert(aField: TField; aSource, aDest: Pointer;
-  aToNative: Boolean);
-  
-var
-  DT : TFieldType;
-  
-begin
-  DT := aField.DataType;
-  if aToNative then
-    begin
-    case DT of
-      ftDate, ftTime, ftDateTime: TDateTimeRec(aDest^) := DateTimeToDateTimeRec(DT, TDateTime(aSource^));
-      ftTimeStamp               : TTimeStamp(aDest^) := TTimeStamp(aSource^);
-      ftBCD                     : TBCD(aDest^) := CurrToBCD(Currency(aSource^));
-      ftFMTBCD                  : TBcd(aDest^) := TBcd(aSource^);
-  // See notes from mantis bug-report 7204 for more information
-  //    ftBytes                   : ;
-  //    ftVarBytes                : ;
-  //    ftWideString              : ;
-
-      end
-    end
-  else
-    begin
-    case DT of
-      ftDate, ftTime, ftDateTime: TDateTime(aDest^) := DateTimeRecToDateTime(DT, TDateTimeRec(aSource^));
-      ftTimeStamp               : TTimeStamp(aDest^) := TTimeStamp(aSource^);
-      ftBCD                     : BCDToCurr(TBCD(aSource^),Currency(aDest^));
-      ftFMTBCD                  : TBcd(aDest^) := TBcd(aSource^);
-  //    ftBytes                   : ;
-  //    ftVarBytes                : ;
-  //    ftWideString              : ;
-
-      end
-    end
-end;
-
-function TDataSet.GetFieldData(Field: TField; Buffer: Pointer;
-  NativeFormat: Boolean): Boolean;
-
-Var
-  AStatBuffer : Array[0..dsMaxStringSize] of Char;
-  ADynBuffer : pchar;
-
-begin
-  If NativeFormat then
-    Result:=GetFieldData(Field, Buffer)
-  else
-    begin
-    if Field.DataSize <= dsMaxStringSize then
-      begin
-      Result := GetfieldData(Field, @AStatBuffer);
-      if Result then DataConvert(Field,@AStatBuffer,Buffer,False);
-      end
-    else
-      begin
-      GetMem(ADynBuffer,Field.DataSize);
-      try
-        Result := GetfieldData(Field, ADynBuffer);
-        if Result then DataConvert(Field,ADynBuffer,Buffer,False);
-      finally
-        FreeMem(ADynBuffer);
-        end;
-      end;
-    end;
-end;
-
-Function DateTimeRecToDateTime(DT: TFieldType; Data: TDateTimeRec): TDateTime;
-
-var
-  TS: TTimeStamp;
-
-begin
-  TS.Date:=0;
-  TS.Time:=0;
-  case DT of
-    ftDate: TS.Date := Data.Date;
-    ftTime: With TS do
-              begin
-              Time := Data.Time;
-              Date := DateDelta;
-              end;
-  else
-    try
-      TS:=MSecsToTimeStamp(trunc(Data.DateTime));
-    except
-    end;
-  end;
-  Result:=TimeStampToDateTime(TS);
-end;
-
-Function DateTimeToDateTimeRec(DT: TFieldType; Data: TDateTime): TDateTimeRec;
-
-var
-  TS : TTimeStamp;
-
-begin
-  TS:=DateTimeToTimeStamp(Data);
-  With Result do
-    case DT of
-      ftDate:
-        Date:=TS.Date;
-      ftTime:
-        Time:=TS.Time;
-    else
-      DateTime:=TimeStampToMSecs(TS);
-    end;
-end;
-
-procedure TDataSet.SetFieldData(Field: TField; Buffer: Pointer);
-
-begin
-// empty procedure
-end;
-
-procedure TDataSet.SetFieldData(Field: TField; Buffer: Pointer;
-  NativeFormat: Boolean);
-
-Var
-  AStatBuffer : Array[0..dsMaxStringSize] of Char;
-  ADynBuffer : pchar;
-
-begin
-  if NativeFormat then
-    SetFieldData(Field, Buffer)
-  else
-    begin
-    if Field.DataSize <= dsMaxStringSize then
-      begin
-      DataConvert(Field,Buffer,@AStatBuffer,True);
-      SetfieldData(Field, @AStatBuffer);
-      end
-    else
-      begin
-      GetMem(ADynBuffer,Field.DataSize);
-      try
-        DataConvert(Field,Buffer,@AStatBuffer,True);
-        SetfieldData(Field, @AStatBuffer);
-      finally
-        FreeMem(ADynBuffer);
-        end;
-      end;
-    end;
-end;
-
-Function TDataset.GetField (Index : Longint) : TField;
-
-begin
-  Result:=FFIeldList[index];
-end;
-
-Function TDataset.GetFieldClass(FieldType: TFieldType): TFieldClass;
-
-begin
-  Result := DefaultFieldClasses[FieldType];
-end;
-
-Function TDataset.GetIsIndexField(Field: TField): Boolean;
-
-begin
-  Result:=False;
-end;
-
-function TDataSet.GetIndexDefs(IndexDefs: TIndexDefs; IndexTypes: TIndexOptions
-  ): TIndexDefs;
-  
-var i,f : integer;
-    IndexFields : TStrings;
-    
-begin
-  IndexDefs.Update;
-  Result := TIndexDefs.Create(Self);
-  Result.Assign(IndexDefs);
-  i := 0;
-  IndexFields := TStringList.Create;
-  while i < result.Count do
-    begin
-    if (not ((IndexTypes = []) and (result[i].Options = []))) and
-       ((IndexTypes * result[i].Options) = []) then
-      begin
-      result.Delete(i);
-      dec(i);
-      end
-    else
-      begin
-      ExtractStrings([';'],[' '],pchar(result[i].Fields),Indexfields);
-      for f := 0 to IndexFields.Count-1 do if FindField(Indexfields[f]) = nil then
-        begin
-        result.Delete(i);
-        dec(i);
-        break;
-        end;
-      end;
-    inc(i);
-    end;
-  IndexFields.Free;
-end;
-
-Function TDataset.GetNextRecord: Boolean;
-
-  procedure ExchangeBuffers(var buf1,buf2 : pointer);
-
-  var tempbuf : pointer;
-
-  begin
-    tempbuf := buf1;
-    buf1 := buf2;
-    buf2 := tempbuf;
-  end;
-
-begin
-{$ifdef dsdebug}
-  Writeln ('Getting next record. Internal RecordCount : ',FRecordCount);
-{$endif}
-  If FRecordCount>0 Then SetCurrentRecord(FRecordCount-1);
-  Result:=GetRecord(FBuffers[FBuffercount],gmNext,True)=grOK;
-
-  if result then
-    begin
-      If FRecordCount=0 then ActivateBuffers;
-      if FRecordcount=FBuffercount then
-        shiftbuffersbackward
-      else
-        begin
-          inc(FRecordCount);
-          FCurrentRecord:=FRecordCount - 1;
-          ExchangeBuffers(Fbuffers[FCurrentRecord],FBuffers[FBuffercount]);
-        end;
-    end
-  else
-    cursorposchanged;
-{$ifdef dsdebug}
-  Writeln ('Result getting next record : ',Result);
-{$endif}
-end;
-
-Function TDataset.GetNextRecords: Longint;
-
-begin
-  Result:=0;
-{$ifdef dsdebug}
-  Writeln ('Getting next record(s), need :',FBufferCount);
-{$endif}
-  While (FRecordCount<FBufferCount) and GetNextRecord do
-    Inc(Result);
-{$ifdef dsdebug}
-  Writeln ('Result Getting next record(S), GOT :',RESULT);
-{$endif}
-end;
-
-Function TDataset.GetPriorRecord: Boolean;
-
-begin
-{$ifdef dsdebug}
-  Writeln ('GetPriorRecord: Getting previous record');
-{$endif}
-  CheckBiDirectional;
-  If FRecordCount>0 Then SetCurrentRecord(0);
-  Result:=GetRecord(FBuffers[FBuffercount],gmPrior,True)=grOK;
-  if result then
-    begin
-      If FRecordCount=0 then ActivateBuffers;
-      shiftbuffersforward;
-
-      if FRecordcount<FBuffercount then
-        inc(FRecordCount);
-    end
-  else
-    cursorposchanged;
-{$ifdef dsdebug}
-  Writeln ('Result getting prior record : ',Result);
-{$endif}
-end;
-
-Function TDataset.GetPriorRecords: Longint;
-
-begin
-  Result:=0;
-{$ifdef dsdebug}
-  Writeln ('Getting previous record(s), need :',FBufferCount);
-{$endif}
-  While (FRecordCount<FbufferCount) and GetPriorRecord do
-    Inc(Result);
-end;
-
-Function TDataset.GetRecNo: Longint;
-
-begin
-  Result := -1;
-end;
-
-Function TDataset.GetRecordCount: Longint;
-
-begin
-  Result := -1;
-end;
-
-Procedure TDataset.InitFieldDefs;
-
-begin
-  if IsCursorOpen then
-    InternalInitFieldDefs
-  else
-    begin
-    try
-      OpenCursor(True);
-    finally
-      CloseCursor;
-      end;
-    end;
-end;
-
-procedure TDataSet.InitFieldDefsFromfields;
-var i : integer;
-begin
-  if FieldDefs.count = 0 then
-    begin
-    FieldDefs.BeginUpdate;
-    try
-      for i := 0 to Fields.Count-1 do with fields[i] do
-        begin
-        with TFieldDef.Create(FieldDefs,FieldName,DataType,Size,Required,i+1) do
-          begin
-          if Required then Attributes := attributes + [faRequired];
-          if ReadOnly then Attributes := attributes + [faReadOnly];
-          if DataType = ftBCD then precision := (fields[i] as TBCDField).Precision
-          // this must change if TFMTBcdfield is implemented
-          else if DataType = ftFMTBcd then precision := (fields[i] as TBCDField).Precision;
-          end;
-        end;
-    finally
-      FieldDefs.EndUpdate;
-      end;
-    end;
-end;
-
-Procedure TDataset.InitRecord(Buffer: PChar);
-
-begin
-  InternalInitRecord(Buffer);
-  ClearCalcFields(Buffer);
-end;
-
-Procedure TDataset.InternalCancel;
-
-begin
-  //!! To be implemented
-end;
-
-Procedure TDataset.InternalEdit;
-
-begin
-  //!! To be implemented
-end;
-
-Procedure TDataset.InternalRefresh;
-
-begin
-  //!! To be implemented
-end;
-
-Procedure TDataset.OpenCursor(InfoQuery: Boolean);
-
-begin
-  if InfoQuery then
-    InternalInitfieldDefs
-  else if state <> dsOpening then
-    DoInternalOpen;
-end;
-
-procedure TDataSet.OpenCursorcomplete;
-begin
-  try
-    if FState = dsOpening then DoInternalOpen
-  finally
-    if FInternalOpenComplete then
-      begin
-      SetState(dsBrowse);
-      DoAfterOpen;
-      if not IsEmpty then
-        DoAfterScroll;
-      end
-    else
-      begin
-      SetState(dsInactive);
-      CloseCursor;
-      end;
-  end;
-end;
-
-Procedure TDataset.RefreshInternalCalcFields(Buffer: PChar);
-
-begin
-  //!! To be implemented
-end;
-
-Function TDataset.SetTempState(const Value: TDataSetState): TDataSetState;
-
-begin
-  result := FState;
-  FState := value;
-  inc(FDisableControlsCount);
-end;
-
-Procedure TDataset.RestoreState(const Value: TDataSetState);
-
-begin
-  FState := value;
-  dec(FDisableControlsCount);
-end;
-
-function TDataset.GetActive : boolean;
-
-begin
-  result := (FState <> dsInactive) and (FState <> dsOpening);
-end;
-
-Procedure TDataset.InternalHandleException;
-
-begin
-  if assigned(classes.ApplicationHandleException) then
-    classes.ApplicationHandleException(self)
-  else
-    ShowException(ExceptObject,ExceptAddr);
-end;
-
-procedure TDataSet.InternalPost;
-
-  Procedure Checkrequired;
-
-  Var I : longint;
-
-  begin
-    For I:=0 to FFieldList.Count-1 do
-      With FFieldList[i] do
-        // Required fields that are NOT autoinc !! Autoinc cannot be set !!
-        if Required and not ReadOnly and
-           (FieldKind=fkData) and Not (DataType=ftAutoInc) and IsNull then
-          DatabaseErrorFmt(SNeedField,[DisplayName],Self);
-  end;
-
-begin
-  Checkrequired;
-end;
-
-procedure TDataSet.SetUniDirectional(const Value: Boolean);
-begin
-  FIsUniDirectional := Value;
-end;
-
-Procedure TDataset.SetActive (Value : Boolean);
-
-begin
-  if value and (Fstate = dsInactive) then
-    begin
-    if csLoading in ComponentState then
-      begin
-      FOpenAfterRead := true;
-      exit;
-      end
-    else
-      begin
-      DoBeforeOpen;
-      try
-        OpenCursor(False);
-      finally
-        if FState <> dsOpening then OpenCursorComplete;
-        end;
-      end;
-    end
-  else if not value and (Fstate <> dsinactive) then
-    begin
-    if not (csDestroying in ComponentState) then DoBeforeClose;
-    SetState(dsInactive);
-    CloseCursor;
-    if not (csDestroying in ComponentState) then DoAfterClose;
-    end
-end;
-
-procedure TDataset.Loaded;
-
-begin
-  inherited;
-  try
-    if FOpenAfterRead then SetActive(true);
-  except
-    if csDesigning in Componentstate then
-      InternalHandleException
-    else
-      raise;
-  end;
-end;
-
-
-procedure TDataSet.RecalcBufListSize;
-
-var
-  i, j, ABufferCount: Integer;
-  DataLink: TDataLink;
-
-begin
-{$ifdef dsdebug}
-  Writeln('Recalculating buffer list size - check cursor');
-{$endif}
-  If Not IsCursorOpen Then
-    Exit;
-{$ifdef dsdebug}
-  Writeln('Recalculating buffer list size');
-{$endif}
-  ABufferCount := DefaultBufferCount;
-  for i := 0 to FDataSources.Count - 1 do
-    for j := 0 to TDataSource(FDataSources[i]).DataLinks.Count - 1 do
-      begin
-      DataLink:=TDataLink(TDataSource(FDataSources[i]).DataLinks[j]);
-      if DataLink.BufferCount>ABufferCount then
-        ABufferCount:=DataLink.BufferCount;
-      end;
-
-  If (FBufferCount=ABufferCount) Then
-    exit;
-
-{$ifdef dsdebug}
-  Writeln('Setting buffer list size');
-{$endif}
-
-  SetBufListSize(ABufferCount);
-{$ifdef dsdebug}
-  Writeln('Getting next buffers');
-{$endif}
-  GetNextRecords;
-  if FRecordCount < FBufferCount then
-    begin
-    FActiveRecord := FActiveRecord + GetPriorRecords;
-    CursorPosChanged;
-    end;
-{$Ifdef dsDebug}
-  WriteLn(
-    'SetBufferCount: FActiveRecord=',FActiveRecord,
-    ' FCurrentRecord=',FCurrentRecord,
-    ' FBufferCount= ',FBufferCount,
-    ' FRecordCount=',FRecordCount);
-{$Endif}
-end;
-
-Procedure TDataset.SetBookmarkStr(const Value: TBookmarkStr);
-
-begin
-  GotoBookMark(Pointer(Value))
-end;
-
-Procedure TDataset.SetBufListSize(Value: Longint);
-
-Var I : longint;
-
-begin
-  if Value = 0 then Value := -1;
-{$ifdef dsdebug}
-  Writeln ('SetBufListSize: ',Value);
-{$endif}
-  If Value=FBufferCount Then
-    exit;
-  If Value>FBufferCount then
-    begin
-{$ifdef dsdebug}
-    Writeln ('   Reallocating memory :',(Value+1)*SizeOf(PChar));
-{$endif}
-    ReAllocMem(FBuffers,(Value+1)*SizeOf(PChar));
-{$ifdef dsdebug}
-    Writeln ('   Filling memory :',(Value+1-FBufferCount)*SizeOf(PChar));
-{$endif}
-    if FBufferCount > 0 then inc(FBufferCount); // Cause FBuffers[FBufferCount] is already allocated
-    FillChar(FBuffers[FBufferCount],(Value+1-FBufferCount)*SizeOF(Pchar),#0);
-{$ifdef dsdebug}
-    Writeln ('   Filled memory :');
-{$endif}
-    Try
-{$ifdef dsdebug}
-      Writeln ('   Assigning buffers :',(Value)*SizeOf(PChar));
-{$endif}
-      For I:=FBufferCount to Value do
-        FBuffers[i]:=AllocRecordBuffer;
-{$ifdef dsdebug}
-      Writeln ('   Assigned buffers ',FBufferCount,' :',(Value)*SizeOf(PChar));
-{$endif}
-    except
-      I:=FBufferCount;
-      While (I<(Value+1)) do
-        begin
-        FreeRecordBuffer(FBuffers[i]);
-        Inc(i);
-        end;
-      raise;
-    end;
-    end
-  else
-    begin
-{$ifdef dsdebug}
-    Writeln ('   Freeing buffers :',FBufferCount-Value);
-{$endif}
-    if (value > -1) and (FActiveRecord>Value-1) then
-      begin
-      for i := 0 to (FActiveRecord-Value) do
-        shiftbuffersbackward;
-      FActiverecord := Value -1;
-      end;
-
-    If Assigned(FBuffers) then
-      begin
-      For I:=Value+1 to FBufferCount do
-        FreeRecordBuffer(FBuffers[i]);
-      // FBuffer must stay allocated, to make sure that Activebuffer returns nil
-      if Value = -1 then
-        begin
-        ReAllocMem(FBuffers,SizeOf(Pchar));
-        FBuffers[0] := nil;
-        end
-      else
-        ReAllocMem(FBuffers,(Value+1)*SizeOf(Pchar));
-      end;
-    end;
-  If Value=-1 then
-    Value:=0;
-  if FRecordcount > Value then FRecordcount := Value;
-  FBufferCount:=Value;
-{$ifdef dsdebug}
-  Writeln ('   SetBufListSize: Final FBufferCount=',FBufferCount);
-{$endif}
-end;
-
-Procedure TDataset.SetChildOrder(Component: TComponent; Order: Longint);
-
-var
-  Field: TField;
-begin
-  Field := Component as TField;
-  if Fields.IndexOf(Field) >= 0 then
-    Field.Index := Order;
-end;
-
-Procedure TDataset.SetCurrentRecord(Index: Longint);
-
-begin
-  If FCurrentRecord<>Index then
-    begin
-{$ifdef DSdebug}
-    Writeln ('Setting current record to',index);
-{$endif}
-    if not FIsUniDirectional then Case GetBookMarkFlag(FBuffers[Index]) of
-      bfCurrent : InternalSetToRecord(FBuffers[Index]);
-      bfBOF : InternalFirst;
-      bfEOF : InternalLast;
-      end;
-    FCurrentRecord:=index;
-    end;
-end;
-
-Procedure TDataset.SetField (Index : Longint;Value : TField);
-
-begin
-  //!! To be implemented
-end;
-
-Procedure TDataset.CheckBiDirectional;
-
-begin
-  if FIsUniDirectional then DataBaseError(SUniDirectional);
-end;
-
-Procedure TDataset.SetFilterOptions(Value: TFilterOptions);
-
-begin
-  CheckBiDirectional;
-  FFilterOptions := Value;
-end;
-
-Procedure TDataset.SetFilterText(const Value: string);
-
-begin
-  FFilterText := value;
-end;
-
-Procedure TDataset.SetFiltered(Value: Boolean);
-
-begin
-  if Value then CheckBiDirectional;
-  FFiltered := value;
-end;
-
-Procedure TDataset.SetFound(const Value: Boolean);
-
-begin
-  FFound := Value;
-end;
-
-Procedure TDataset.SetModified(Value: Boolean);
-
-begin
-  FModified := value;
-end;
-
-Procedure TDataset.SetName(const Value: TComponentName);
-
-function CheckName(FieldName: string): string;
-var i,j: integer;
-begin
-  Result := FieldName;
-  i := 0;
-  j := 0;
-  while (i < Fields.Count) do begin
-    if Result = Fields[i].FieldName then begin
-      inc(j);
-      Result := FieldName + IntToStr(j);
-    end else Inc(i);
-  end;
-end;
-var i: integer;
-    nm: string;
-    old: string;
-begin
-  if Self.Name = Value then Exit;
-  old := Self.Name;
-  inherited SetName(Value);
-  if (csDesigning in ComponentState) then
-    for i := 0 to Fields.Count - 1 do begin
-      nm := old + Fields[i].FieldName;
-      if Copy(Fields[i].Name, 1, Length(nm)) = nm then
-        Fields[i].Name := CheckName(Value + Fields[i].FieldName);
-    end;
-end;
-
-Procedure TDataset.SetOnFilterRecord(const Value: TFilterRecordEvent);
-
-begin
-  CheckBiDirectional;
-  FOnFilterRecord := Value;
-end;
-
-Procedure TDataset.SetRecNo(Value: Longint);
-
-begin
-  //!! To be implemented
-end;
-
-Procedure TDataset.SetState(Value: TDataSetState);
-
-begin
-  If Value<>FState then
-    begin
-    FState:=Value;
-    DataEvent(deUpdateState,0);
-    end;
-end;
-
-Function TDataset.Tempbuffer: PChar;
-
-begin
-  Result := FBuffers[FRecordCount];
-end;
-
-Procedure TDataset.UpdateIndexDefs;
-
-begin
-  // Empty Abstract
-end;
-
-Function TDataset.ControlsDisabled: Boolean;
-
-begin
-  Result := (FDisableControlsCount > 0);
-end;
-
-Function TDataset.ActiveBuffer: PChar;
-
-begin
-{$ifdef dsdebug}
-  Writeln ('Active buffer requested. Returning:',ActiveRecord);
-{$endif}
-  Result:=FBuffers[FActiveRecord];
-end;
-
-Procedure TDataset.Append;
-
-begin
-  DoInsertAppend(True);
-end;
-
-Procedure TDataset.InternalInsert;
-
-begin
-  //!! To be implemented
-end;
-
-Procedure TDataset.AppendRecord(const Values: array of const);
-
-begin
-  //!! To be implemented
-end;
-
-Function TDataset.BookmarkValid(ABookmark: TBookmark): Boolean;
-{
-  Should be overridden by descendant objects.
-}
-begin
-  Result:=False
-end;
-
-Procedure TDataset.Cancel;
-
-begin
-  If State in [dsEdit,dsInsert] then
-    begin
-    DataEvent(deCheckBrowseMode,0);
-    DoBeforeCancel;
-    UpdateCursorPos;
-    InternalCancel;
-    FreeFieldBuffers;
-    if (state = dsInsert) and (FRecordcount = 1) then
-      begin
-      FEOF := true;
-      FBOF := true;
-      FRecordcount := 0;
-      InitRecord(ActiveBuffer);
-      SetState(dsBrowse);
-      DataEvent(deDatasetChange,0);
-      end
-    else
-      begin
-      SetState(dsBrowse);
-      SetCurrentRecord(FActiverecord);
-      resync([]);
-      end;
-    DoAfterCancel;
-    end;
-end;
-
-Procedure TDataset.CheckBrowseMode;
-
-begin
-  CheckActive;
-  DataEvent(deCheckBrowseMode,0);
-  Case State of
-    dsedit,dsinsert: begin
-      UpdateRecord;
-      If Modified then Post else Cancel;
-    end;
-    dsSetKey: Post;
-  end;
-end;
-
-Procedure TDataset.ClearFields;
-
-
-begin
-  DataEvent(deCheckBrowseMode, 0);
-  FreeFieldBuffers;
-  InternalInitRecord(ActiveBuffer);
-  if State <> dsSetKey then GetCalcFields(ActiveBuffer);
-  DataEvent(deRecordChange, 0);
-end;
-
-Procedure TDataset.Close;
-
-begin
-  Active:=False;
-end;
-
-Function TDataset.CompareBookmarks(Bookmark1, Bookmark2: TBookmark): Longint;
-
-begin
-  Result:=0;
-end;
-
-Function TDataset.CreateBlobStream(Field: TField; Mode: TBlobStreamMode): TStream;
-
-
-begin
-  Result:=Nil;
-end;
-
-Procedure TDataset.CursorPosChanged;
-
-
-begin
-  FCurrentRecord:=-1;
-end;
-
-Procedure TDataset.Delete;
-
-begin
-  If Not CanModify then
-    DatabaseError(SDatasetReadOnly,Self);
-  If IsEmpty then
-    DatabaseError(SDatasetEmpty,Self);
-  if State in [dsInsert] then
-  begin
-    Cancel;
-  end else begin
-    DataEvent(deCheckBrowseMode,0);
-{$ifdef dsdebug}
-    writeln ('Delete: checking required fields');
-{$endif}
-    DoBeforeDelete;
-    DoBeforeScroll;
-    If Not TryDoing(@InternalDelete,OnPostError) then exit;
-{$ifdef dsdebug}
-    writeln ('Delete: Internaldelete succeeded');
-{$endif}
-    FreeFieldBuffers;
-    SetState(dsBrowse);
-{$ifdef dsdebug}
-    writeln ('Delete: Browse mode set');
-{$endif}
-    SetCurrentRecord(FActiverecord);
-    Resync([]);
-    DoAfterDelete;
-    DoAfterScroll;
-  end;
-end;
-
-Procedure TDataset.DisableControls;
-
-
-begin
-  If FDisableControlsCount=0 then
-    begin
-    { Save current state,
-      needed to detect change of state when enabling controls.
-    }
-    FDisableControlsState:=FState;
-    FEnableControlsEvent:=deDatasetChange;
-    end;
-  Inc(FDisableControlsCount);
-end;
-
-Procedure TDataset.DoInsertAppend(DoAppend : Boolean);
-
-
-  procedure DoInsert(DoAppend : Boolean);
-
-  Var BookBeforeInsert : TBookmarkStr;
-      TempBuf : pointer;
-
-  begin
-  // need to scroll up al buffers after current one,
-  // but copy current bookmark to insert buffer.
-  If FRecordcount > 0 then
-    BookBeforeInsert:=Bookmark;
-
-  if not DoAppend then
-    begin
-    if FRecordCount > 0 then
-      begin
-      TempBuf := FBuffers[FBuffercount];
-      move(FBuffers[FActiveRecord],FBuffers[FActiveRecord+1],(Fbuffercount-FActiveRecord)*sizeof(FBuffers[0]));
-      FBuffers[FActiveRecord]:=TempBuf;
-      end;
-    end
-  else if FRecordcount=FBuffercount then
-    shiftbuffersbackward
-  else
-    begin
-    if FRecordCount>0 then
-      inc(FActiveRecord);
-    end;
-
-  // Active buffer is now edit buffer. Initialize.
-  InitRecord(FBuffers[FActiveRecord]);
-  cursorposchanged;
-
-  // Put bookmark in edit buffer.
-  if FRecordCount=0 then
-    SetBookmarkFlag(ActiveBuffer,bfEOF)
-  else
-    begin
-    fBOF := false;
-    // 29:01:05, JvdS: Why is this here?!? It can result in records with the same bookmark-data?
-    // I would say that the 'internalinsert' should do this. But I don't know how Tdbf handles it
-
-    // 1-apr-06, JvdS: It just sets the bookmark of the newly inserted record to the place
-    // where the record should be inserted. So it is ok.
-    if FRecordcount > 0 then
-      SetBookMarkData(ActiveBuffer,pointer(BookBeforeInsert));
-    end;
-
-  InternalInsert;
-
-  // update buffer count.
-  If FRecordCount<FBufferCount then
-    Inc(FRecordCount);
-  end;
-
-begin
-  CheckBrowseMode;
-  If Not CanModify then
-    DatabaseError(SDatasetReadOnly,Self);
-  DoBeforeInsert;
-  DoBeforeScroll;
-  If Not DoAppend then
-    begin
-{$ifdef dsdebug}
-    Writeln ('going to insert mode');
-{$endif}
-    DoInsert(false);
-    end
-  else
-    begin
-{$ifdef dsdebug}
-    Writeln ('going to append mode');
-{$endif}
-    ClearBuffers;
-    InternalLast;
-    GetPriorRecords;
-    if FRecordCount>0 then
-      FActiveRecord:=FRecordCount-1;
-    DoInsert(True);
-    SetBookmarkFlag(ActiveBuffer,bfEOF);
-    FBOF :=False;
-    FEOF := true;
-    end;
-  SetState(dsInsert);
-  try
-    DoOnNewRecord;
-  except
-    SetCurrentRecord(FActiverecord);
-    resync([]);
-    raise;
-  end;
-  // mark as not modified.
-  FModified:=False;
-  // Final events.
-  DataEvent(deDatasetChange,0);
-  DoAfterInsert;
-  DoAfterScroll;
-{$ifdef dsdebug}
-  Writeln ('Done with append');
-{$endif}
-end;
-
-Procedure TDataset.Edit;
-
-begin
-  CheckBrowseMode;
-  If Not CanModify then
-    DatabaseError(SDatasetReadOnly,Self);
-  If State in [dsedit,dsinsert] then exit;
-  If FRecordCount = 0 then
-    begin
-    Append;
-    Exit;
-    end;
-  DoBeforeEdit;
-  If Not TryDoing(@InternalEdit,OnEditError) then exit;
-  GetCalcFields(ActiveBuffer);
-  SetState(dsedit);
-  DataEvent(deRecordChange,0);
-  DoAfterEdit;
-end;
-
-Procedure TDataset.EnableControls;
-
-
-begin
-  If FDisableControlsCount>0 then
-    begin
-    Dec(FDisableControlsCount);
-    If FDisableControlsCount=0 then
-      begin
-      // State changed since disablecontrols ?
-      If FDisableControlsState<>FState then
-        DataEvent(deUpdateState,0);
-      If (FDisableControlsState<>dsInactive) and (FState<>dsInactive) then
-        DataEvent(FEnableControlsEvent,0);
-      end;
-    end;
-end;
-
-Function TDataset.FieldByName(const FieldName: string): TField;
-
-
-begin
-  Result:=FindField(FieldName);
-  If Result=Nil then
-    DatabaseErrorFmt(SFieldNotFound,[FieldName],Self);
-end;
-
-Function TDataset.FindField(const FieldName: string): TField;
-
-
-begin
-  Result:=FFieldList.FindField(FieldName);
-end;
-
-Function TDataset.FindFirst: Boolean;
-
-
-begin
-  Result:=False;
-end;
-
-Function TDataset.FindLast: Boolean;
-
-
-begin
-  Result:=False;
-end;
-
-Function TDataset.FindNext: Boolean;
-
-
-begin
-  Result:=False;
-end;
-
-Function TDataset.FindPrior: Boolean;
-
-
-begin
-  Result:=False;
-end;
-
-Procedure TDataset.First;
-
-
-begin
-  CheckBrowseMode;
-  DoBeforeScroll;
-  if not FIsUniDirectional then
-    ClearBuffers
-  else if not FBof then
-    begin
-    Active := False;
-    Active := True;
-    end;
-  try
-    InternalFirst;
-    if not FIsUniDirectional then GetNextRecords;
-  finally
-    FBOF:=True;
-    DataEvent(deDatasetChange,0);
-    DoAfterScroll;
-    end;
-end;
-
-Procedure TDataset.FreeBookmark(ABookmark: TBookmark);
-
-
-begin
-  FreeMem(ABookMark,FBookMarkSize);
-end;
-
-Function TDataset.GetBookmark: TBookmark;
-
-
-begin
-  if BookmarkAvailable then
-    begin
-    GetMem (Result,FBookMarkSize);
-    GetBookMarkdata(ActiveBuffer,Result);
-    end
-  else
-    Result:=Nil;
-end;
-
-Function TDataset.GetCurrentRecord(Buffer: PChar): Boolean;
-
-
-begin
-  Result:=False;
-end;
-
-Procedure TDataset.GetFieldList(List: TList; const FieldNames: string);
-
-  Function NextName(Var S : String) : String;
-
-  Var
-    P : integer;
-
-  begin
-    P:=Pos(';',S);
-    If (P=0) then
-      P:=Length(S)+1;
-    Result:=Copy(S,1,P-1);
-    system.Delete(S,1,P);
-  end;
-
-var
-  F: TField;
-  Names,N : String;
-
-begin
-  Names:=FieldNames;
-  N:=Nextname(Names);
-  while (N<>'') do
-    begin
-    F:=FieldByName(N);
-    If Assigned(List) then
-      List.Add(F);
-    N:=NextName(Names);
-    end;
-end;
-
-Procedure TDataset.GetFieldNames(List: TStrings);
-
-
-begin
-  FFieldList.GetFieldNames(List);
-end;
-
-Procedure TDataset.GotoBookmark(ABookmark: TBookmark);
-
-
-begin
-  If Assigned(ABookMark) then
-    begin
-    CheckBrowseMode;
-    DoBeforeScroll;
-    InternalGotoBookMark(ABookMark);
-    Resync([rmExact,rmCenter]);
-    DoAfterScroll;
-    end;
-end;
-
-Procedure TDataset.Insert;
-
-begin
-  DoInsertAppend(False);
-end;
-
-Procedure TDataset.InsertRecord(const Values: array of const);
-
-
-begin
-  //!! To be implemented
-end;
-
-Function TDataset.IsEmpty: Boolean;
-
-begin
-  Result:=(fBof and fEof) and
-          (not (state = dsinsert)); // After an insert on an empty dataset, both fBof and fEof are true
-end;
-
-Function TDataset.IsLinkedTo(ADataSource: TDataSource): Boolean;
-
-begin
-//!! Not tested, I never used nested DS
-  if (ADataSource = nil) or (ADataSource.Dataset = nil) then begin
-    Result := False
-  end else if ADataSource.Dataset = Self then begin
-    Result := True;
-  end else begin
-    Result := ADataSource.Dataset.IsLinkedTo(ADataSource.Dataset.DataSource);
-  end;
-//!! DataSetField not implemented
-end;
-
-Function TDataset.IsSequenced: Boolean;
-
-begin
-  Result := True;
-end;
-
-Procedure TDataset.Last;
-
-begin
-  CheckBiDirectional;
-  CheckBrowseMode;
-  DoBeforeScroll;
-  ClearBuffers;
-  try
-    InternalLast;
-    GetPriorRecords;
-    if FRecordCount>0 then
-      FActiveRecord:=FRecordCount-1
-  finally
-    FEOF:=true;
-    DataEvent(deDataSetChange, 0);
-    DoAfterScroll;
-    end;
-end;
-
-Function TDataset.MoveBy(Distance: Longint): Longint;
-Var
-  TheResult: Integer;
-
-  Function Scrollforward : Integer;
-
-  begin
-    Result:=0;
-{$ifdef dsdebug}
-    Writeln('Scrolling forward :',Distance);
-    Writeln('Active buffer : ',FActiveRecord);
-    Writeln('RecordCount   : ',FRecordCount);
-    WriteLn('BufferCount   : ',FBufferCount);
-{$endif}
-    FBOF:=False;
-    While (Distance>0) and not FEOF do
-      begin
-      If FActiveRecord<FRecordCount-1 then
-        begin
-        Inc(FActiveRecord);
-        Dec(Distance);
-        Inc(TheResult); //Inc(Result);
-        end
-      else
-        begin
-{$ifdef dsdebug}
-       Writeln('Moveby : need next record');
-{$endif}
-        If GetNextRecord then
-          begin
-          Dec(Distance);
-          Dec(Result);
-          Inc(TheResult); //Inc(Result);
-          end
-        else
-          FEOF:=true;
-        end;
-      end
-  end;
-  Function ScrollBackward : Integer;
-
-  begin
-    CheckBiDirectional;
-    Result:=0;
-{$ifdef dsdebug}
-    Writeln('Scrolling backward:',Abs(Distance));
-    Writeln('Active buffer : ',FActiveRecord);
-    Writeln('RecordCunt    : ',FRecordCount);
-    WriteLn('BufferCount   : ',FBufferCount);
-{$endif}
-    FEOF:=False;
-    While (Distance<0) and not FBOF do
-      begin
-      If FActiveRecord>0 then
-        begin
-        Dec(FActiveRecord);
-        Inc(Distance);
-        Dec(TheResult); //Dec(Result);
-        end
-      else
-        begin
-       {$ifdef dsdebug}
-       Writeln('Moveby : need next record');
-       {$endif}
-        If GetPriorRecord then
-          begin
-          Inc(Distance);
-          Inc(Result);
-          Dec(TheResult); //Dec(Result);
-          end
-        else
-          FBOF:=true;
-        end;
-      end
-  end;
-
-Var
-  Scrolled : Integer;
-
-begin
-  CheckBrowseMode;
-  Result:=0; TheResult:=0;
-  DoBeforeScroll;
-  If (Distance = 0) or
-     ((Distance>0) and FEOF) or
-     ((Distance<0) and FBOF) then
-    exit;
-  Try
-    Scrolled := 0;
-    If Distance>0 then
-      Scrolled:=ScrollForward
-    else
-      Scrolled:=ScrollBackward;
-  finally
-{$ifdef dsdebug}
-    WriteLn('ActiveRecord=', FActiveRecord,' FEOF=',FEOF,' FBOF=',FBOF);
-{$Endif}
-    DataEvent(deDatasetScroll,Scrolled);
-    DoAfterScroll;
-    Result:=TheResult;
-  end;
-end;
-
-Procedure TDataset.Next;
-
-begin
-  MoveBy(1);
-end;
-
-Procedure TDataset.Open;
-
-begin
-  Active:=True;
-end;
-
-Procedure TDataset.Post;
-
-begin
-  if State in [dsEdit,dsInsert] then
-    begin
-    DataEvent(deUpdateRecord,0);
-    DataEvent(deCheckBrowseMode,0);
-{$ifdef dsdebug}
-    writeln ('Post: checking required fields');
-{$endif}
-    DoBeforePost;
-    If Not TryDoing(@InternalPost,OnPostError) then exit;
-    cursorposchanged;
-{$ifdef dsdebug}
-    writeln ('Post: Internalpost succeeded');
-{$endif}
-    FreeFieldBuffers;
-// First set the state to dsBrowse, then the Resync, to prevent the calling of
-// the deDatasetChange event, while the state is still 'editable', while the db isn't
-    SetState(dsBrowse);
-    Resync([]);
-{$ifdef dsdebug}
-    writeln ('Post: Browse mode set');
-{$endif}
-    DoAfterPost;
-    end
-  else
-    DatabaseErrorFmt(SNotEditing, [Name], Self);
-end;
-
-Procedure TDataset.Prior;
-
-begin
-  MoveBy(-1);
-end;
-
-Procedure TDataset.Refresh;
-
-begin
-  CheckbrowseMode;
-  DoBeforeRefresh;
-  UpdateCursorPos;
-  InternalRefresh;
-{ SetCurrentRecord is called by UpdateCursorPos already, so as long as
-  InternalRefresh doesn't do strange things this should be ok. }
-//  SetCurrentRecord(FActiverecord);
-  Resync([]);
-  DoAfterRefresh;
-end;
-
-Procedure TDataset.RegisterDataSource(ADatasource : TDataSource);
-
-begin
-  FDatasources.Add(ADataSource);
-  RecalcBufListSize;
-end;
-
-
-Procedure TDataset.Resync(Mode: TResyncMode);
-
-var i,count : integer;
-
-begin
-  // See if we can find the requested record.
-{$ifdef dsdebug}
-    Writeln ('Resync called');
-{$endif}
-  if FIsUnidirectional then Exit;
-// place the cursor of the underlying dataset to the active record
-//  SetCurrentRecord(FActiverecord);
-
-// Now look if the data on the current cursor of the underlying dataset is still available
-  If GetRecord(Fbuffers[0],gmcurrent,False)<>grOk Then
-// If that fails and rmExact is set, then raise an exception
-    If rmExact in Mode then
-      DatabaseError(SNoSuchRecord,Self)
-// else, if rmexact is not set, try to fetch the next  or prior record in the underlying dataset
-    else if (GetRecord(Fbuffers[0],gmnext,True)<>grOk) and
-            (GetRecord(Fbuffers[0],gmprior,True)<>grOk) then
-      begin
-{$ifdef dsdebug}
-      Writeln ('Resync: fuzzy resync');
-{$endif}
-      // nothing found, invalidate buffer and bail out.
-      ClearBuffers;
-      // Make sure that the active record is 'empty', ie: that all fields are null
-      InternalInitRecord(ActiveBuffer);
-      DataEvent(deDatasetChange,0);
-      exit;
-      end;
-  FCurrentRecord := 0;
-  FEOF := false;
-  FBOF := false;
-
-// If we've arrived here, FBuffer[0] is the current record
-  If (rmCenter in Mode) then
-    count := (FRecordCount div 2)
-  else
-    count := FActiveRecord;
-  i := 0;
-  FRecordcount := 1;
-  FActiveRecord := 0;
-
-// Fill the buffers before the active record
-  while (i < count) and GetPriorRecord do
-    inc(i);
-  FActiveRecord := i;
-// Fill the rest of the buffer
-  getnextrecords;
-// If the buffer is not full yet, try to fetch some more prior records
-  if FRecordcount < FBuffercount then inc(FActiverecord,getpriorrecords);
-// That's all folks!
-  DataEvent(deDatasetChange,0);
-end;
-
-Procedure TDataset.SetFields(const Values: array of const);
-
-Var I  : longint;
-begin
-  For I:=0 to high(Values) do
-    Fields[I].AssignValue(Values[I]);
-end;
-
-Function TDataset.Translate(Src, Dest: PChar; ToOem: Boolean): Integer;
-
-begin
-  strcopy(dest,src);
-  Result:=StrLen(dest);
-end;
-
-Function Tdataset.TryDoing (P : TDataOperation; Ev : TDatasetErrorEvent) : Boolean;
-
-Var Retry : TDataAction;
-
-begin
-{$ifdef dsdebug}
-  Writeln ('Trying to do');
-  If P=Nil then writeln ('Procedure to call is nil !!!');
-{$endif dsdebug}
-  Result:=True;
-  Retry:=daRetry;
-  while Retry=daRetry do
-    Try
-{$ifdef dsdebug}
-      Writeln ('Trying : updatecursorpos');
-{$endif dsdebug}
-      UpdateCursorPos;
-{$ifdef dsdebug}
-      Writeln ('Trying to do it');
-{$endif dsdebug}
-      P;
-      exit;
-    except
-      On E : EDatabaseError do
-        begin
-        retry:=daFail;
-        If Assigned(Ev) then
-          Ev(Self,E,Retry);
-        Case Retry of
-          daFail : Raise;
-          daAbort : Result:=False;
-        end;
-        end;
-    else
-      Raise;
-    end;
-{$ifdef dsdebug}
-  Writeln ('Exit Trying to do');
-{$endif dsdebug}
-end;
-
-Procedure TDataset.UpdateCursorPos;
-
-begin
-  If FRecordCount>0 then
-    SetCurrentRecord(FactiveRecord);
-end;
-
-Procedure TDataset.UpdateRecord;
-
-begin
-  if not (State in dsEditModes) then
-    DatabaseErrorFmt(SNotEditing, [Name], Self);
-  DataEvent(deUpdateRecord, 0);
-end;
-
-Function TDataSet.UpdateStatus: TUpdateStatus;
-
-begin
-  Result:=usUnmodified;
-end;
-
-Procedure TDataset.RemoveField (Field : TField);
-
-begin
-  //!! To be implemented
-end;
-
-Function TDataset.Getfieldcount : Longint;
-
-begin
-  Result:=FFieldList.Count;
-end;
-
-Procedure TDataset.ShiftBuffersBackward;
-
-var TempBuf : pointer;
-
-begin
-  TempBuf := FBuffers[0];
-  move(FBuffers[1],FBuffers[0],(fbuffercount)*sizeof(FBuffers[0]));
-  FBuffers[buffercount]:=TempBuf;
-end;
-
-Procedure TDataset.ShiftBuffersForward;
-
-var TempBuf : pointer;
-
-begin
-  TempBuf := FBuffers[FBufferCount];
-  move(FBuffers[0],FBuffers[1],(fbuffercount)*sizeof(FBuffers[0]));
-  FBuffers[0]:=TempBuf;
-end;
-
-function TDataset.GetFieldValues(Fieldname: string): Variant;
-
-var i: Integer;
-    FieldList: TList;
-begin
-  if Pos(';', FieldName) <> 0 then begin
-    FieldList := TList.Create;
-    try
-      GetFieldList(FieldList, FieldName);
-      Result := VarArrayCreate([0, FieldList.Count - 1], varVariant);
-      for i := 0 to FieldList.Count - 1 do
-        Result[i] := TField(FieldList[i]).Value;
-    finally
-      FieldList.Free;
-    end;
-  end else
-    Result := FieldByName(FieldName).Value
-end;
-
-procedure TDataset.SetFieldValues(Fieldname: string; Value: Variant);
-
-var i: Integer;
-    FieldList: TList;
-begin
-  if Pos(';', FieldName) <> 0 then
-  begin
-    FieldList := TList.Create;
-    try
-      GetFieldList(FieldList, FieldName);
-      for i := 0 to FieldList.Count - 1 do
-        TField(FieldList[i]).Value := Value[i];
-    finally
-      FieldList.Free;
-    end;
-  end else
-    FieldByName(FieldName).Value := Value;
-end;
-
-Function TDataset.Locate(const keyfields: string; const keyvalues: Variant; options: TLocateOptions) : boolean;
-
-begin
-  CheckBiDirectional;
-  Result := False;
-end;
-
-Function TDataset.Lookup(const KeyFields: string; const KeyValues: Variant; const ResultFields: string): Variant;
-
-begin
-  Result := False;
-end;
-
-
-Procedure TDataset.UnRegisterDataSource(ADatasource : TDatasource);
-
-begin
-  FDataSources.Remove(ADataSource);
-end;
-

+ 0 - 676
packages/fcl-db/src/datasource.inc

@@ -1,676 +0,0 @@
-{ ---------------------------------------------------------------------
-    TDatalink
-  ---------------------------------------------------------------------}
-
-Constructor TDataLink.Create;
-
-begin
-  Inherited Create;
-  FBufferCount:=1;
-  FFirstRecord := 0;
-  FDataSource := nil;
-  FDatasourceFixed:=False;
-end;
-
-
-Destructor TDataLink.Destroy;
-
-begin
-  Factive:=False;
-  FEditing:=False;
-  FDataSourceFixed:=False;
-  DataSource:=Nil;
-  Inherited Destroy;
-end;
-
-
-Procedure TDataLink.ActiveChanged;
-
-begin
-  FFirstRecord := 0;
-end;
-
-Procedure TDataLink.CheckActiveAndEditing;
-
-Var
-  B : Boolean;
-
-begin
-  B:=Assigned(DataSource) and (DataSource.State<>dsInactive);
-  If B<>FActive then
-    begin
-    FActive:=B;
-    ActiveChanged;
-    end;
-  B:=Assigned(DataSource) and (DataSource.State in dsEditModes) and Not FReadOnly;
-  If B<>FEditing Then
-    begin
-    FEditing:=B;
-    EditingChanged;
-    end;
-end;
-
-
-Procedure TDataLink.CheckBrowseMode;
-
-begin
-end;
-
-
-Function TDataLink.CalcFirstRecord(Index : Integer) : Integer;
-
-{ recalculates index of first record in buffer,
-  and returns number of record scrolled.}
-
-Var
-   A,              // Index of active record in buffer
-   F,              // Index of current first record in buffer
-   L : Integer;    // index of Last (for us) record in buffer;
-
-begin
-  Result:=0;
-  A:=DataSource.DataSet.FActiveRecord;
-  F:=FFirstRecord+Index;
-  L:=F+FBufferCount-1;
-  If A>L Then
-    Result:=A-L
-  else If A<F Then
-    Result:=A-F;
-  FFirstRecord:=F+Result;
-{$IfDef dsDebug}
-  WriteLn('CalcFirstRecord: FFirstRecord=',FFirstRecord,' Scrolled=',Result);
-{$Endif}
-end;
-
-
-Procedure TDataLink.CalcRange;
-var
-    aMax, aMin: integer;
-begin
-  aMin:= DataSet.FActiveRecord - FBufferCount + 1;
-  If aMin < 0 Then aMin:= 0;
-  aMax:= Dataset.FBufferCount - FBufferCount;
-  If aMax < 0 then aMax:= 0;
-
-  If aMax>DataSet.FActiveRecord Then aMax:=DataSet.FActiveRecord;
-
-  If FFirstRecord < aMin Then FFirstRecord:= aMin;
-  If FFirstrecord > aMax Then FFirstRecord:= aMax;
-
-  If (FfirstRecord<>0) And
-     (DataSet.FActiveRecord - FFirstRecord < FBufferCount -1) Then
-    Dec(FFirstRecord, 1);
-
-end;
-
-
-Procedure TDataLink.DataEvent(Event: TDataEvent; Info: Ptrint);
-
-
-begin
-  Case Event of
-    deFieldChange, deRecordChange:
-      If Not FUpdatingRecord then
-        RecordChanged(TField(Info));
-    deDataSetChange: begin
-      SetActive(DataSource.DataSet.Active);
-      CalcRange;
-      CalcFirstRecord(Info);
-      DatasetChanged;
-    end;
-    deDataSetScroll: DatasetScrolled(CalcFirstRecord(Info));
-    deLayoutChange: begin
-      CalcFirstRecord(Info);
-      LayoutChanged;
-    end;
-    deUpdateRecord: UpdateRecord;
-    deUpdateState: CheckActiveAndEditing;
-    deCheckBrowseMode: CheckBrowseMode;
-    deFocusControl: FocusControl(TFieldRef(Info));
-  end;
-end;
-
-
-Procedure TDataLink.DataSetChanged;
-
-begin
-  RecordChanged(Nil);
-end;
-
-
-Procedure TDataLink.DataSetScrolled(Distance: Integer);
-
-begin
-  DataSetChanged;
-end;
-
-
-Procedure TDataLink.EditingChanged;
-
-begin
-end;
-
-
-Procedure TDataLink.FocusControl(Field: TFieldRef);
-
-begin
-end;
-
-
-Function TDataLink.GetActiveRecord: Integer;
-
-begin
-  Result:=Dataset.FActiveRecord - FFirstRecord;
-end;
-
-Function TDatalink.GetDataSet : TDataset;
-
-begin
-  If Assigned(Datasource) then
-    Result:=DataSource.DataSet
-  else
-    Result:=Nil;  
-end;
-
-
-Function TDataLink.GetBOF: Boolean;
-
-begin
-  Result:=DataSet.BOF
-end;
-
-
-Function TDataLink.GetBufferCount: Integer;
-
-begin
-  Result:=FBufferCount;
-end;
-
-
-Function TDataLink.GetEOF: Boolean;
-
-begin
-  Result:=DataSet.EOF
-end;
-
-
-Function TDataLink.GetRecordCount: Integer;
-
-begin
-  Result:=Dataset.FRecordCount;
-  If Result>BufferCount then
-    Result:=BufferCount;
-end;
-
-
-Procedure TDataLink.LayoutChanged;
-
-begin
-  DataSetChanged;
-end;
-
-
-Function TDataLink.MoveBy(Distance: Integer): Integer;
-
-begin
-  Result:=DataSet.MoveBy(Distance);
-end;
-
-
-Procedure TDataLink.RecordChanged(Field: TField);
-
-begin
-end;
-
-
-Procedure TDataLink.SetActiveRecord(Value: Integer);
-
-begin
-{$ifdef dsdebug}
-  Writeln('Datalink. Setting active record to ',Value,' with firstrecord ',ffirstrecord);
-{$endif}
-  Dataset.FActiveRecord:=Value + FFirstRecord;
-end;
-
-
-Procedure TDataLink.SetBufferCount(Value: Integer);
-
-begin
-  If FBufferCount<>Value then
-    begin
-      FBufferCount:=Value;
-      if Active then begin
-        DataSet.RecalcBufListSize;
-        CalcRange;
-      end;
-    end;
-end;
-
-procedure TDataLink.SetActive(AActive: Boolean);
-begin
-  if Active <> AActive then
-  begin
-    FActive := AActive;
-    // !!!: Set internal state
-    ActiveChanged;
-  end;
-end;
-
-Procedure TDataLink.SetDataSource(Value : TDatasource);
-
-begin
-  if not FDataSourceFixed then
-    begin
-    if Assigned(DataSource) then
-      Begin
-      DataSource.UnregisterDatalink(Self);
-      FDataSource := nil;
-      CheckActiveAndEditing;
-      End;
-    FDataSource := Value;
-    if Assigned(DataSource) then
-      begin
-      DataSource.RegisterDatalink(Self);
-      CheckActiveAndEditing;
-      End;
-    end;
-end;
-
-Procedure TDatalink.SetReadOnly(Value : Boolean);
-
-begin
-  If FReadOnly<>Value then
-    begin
-    FReadOnly:=Value;
-    CheckActiveAndEditing;
-    end;
-end;
-
-Procedure TDataLink.UpdateData;
-
-begin
-end;
-
-
-
-Function TDataLink.Edit: Boolean;
-
-begin
-  If Not FReadOnly then
-    DataSource.Edit;
-  // Triggered event will set FEditing
-  Result:=FEditing;
-end;
-
-
-Procedure TDataLink.UpdateRecord;
-
-begin
-  FUpdatingRecord:=True;
-  Try
-    UpdateData;
-  finally
-    FUpdatingRecord:=False;
-  end;
-end;
-
-
-
-{ ---------------------------------------------------------------------
-    TDetailDataLink
-  ---------------------------------------------------------------------}
-
-Function TDetailDataLink.GetDetailDataSet: TDataSet;
-
-begin
-  Result := nil;
-end;
-
-
-{ ---------------------------------------------------------------------
-    TMasterDataLink
-  ---------------------------------------------------------------------}
-
-constructor TMasterDataLink.Create(ADataSet: TDataSet);
-
-begin
-  inherited Create;
-  FDetailDataSet:=ADataSet;
-  FFields:=TList.Create;
-end;
-
-
-destructor TMasterDataLink.Destroy;
-
-begin
-  FFields.Free;
-  inherited Destroy;
-end;
-
-
-Procedure TMasterDataLink.ActiveChanged;
-
-begin
-  FFields.Clear;
-  if Active then
-  try
-    DataSet.GetFieldList(FFields, FFieldNames);
-  except
-    FFields.Clear;
-    raise;
-  end;
-  if FDetailDataSet.Active and not (csDestroying in FDetailDataSet.ComponentState) then
-    if Active and (FFields.Count > 0) then
-      DoMasterChange
-    else
-      DoMasterDisable;  
-end;
-
-
-Procedure TMasterDataLink.CheckBrowseMode;
-
-begin
-  if FDetailDataSet.Active then FDetailDataSet.CheckBrowseMode;
-end;
-
-
-Function TMasterDataLink.GetDetailDataSet: TDataSet;
-
-begin
-  Result := FDetailDataSet;
-end;
-
-
-Procedure TMasterDataLink.LayoutChanged;
-
-begin
-  ActiveChanged;
-end;
-
-
-Procedure TMasterDataLink.RecordChanged(Field: TField);
-
-begin
-  if (DataSource.State <> dsSetKey) and FDetailDataSet.Active and
-     (FFields.Count > 0) and ((Field = nil) or
-     (FFields.IndexOf(Field) >= 0)) then
-    DoMasterChange;  
-end;
-
-procedure TMasterDatalink.SetFieldNames(const Value: string);
-
-begin
-  if FFieldNames <> Value then
-    begin
-    FFieldNames := Value;
-    ActiveChanged;
-    end;
-end;
-
-Procedure TMasterDataLink.DoMasterDisable; 
-
-begin
-  if Assigned(FOnMasterDisable) then 
-    FOnMasterDisable(Self);
-end;
-
-Procedure TMasterDataLink.DoMasterChange; 
-
-begin
-  If Assigned(FOnMasterChange) then
-    FOnMasterChange(Self);
-end;
-
-{ ---------------------------------------------------------------------
-    TMasterDataLink
-  ---------------------------------------------------------------------}
-
-constructor TMasterParamsDataLink.Create(ADataSet: TDataSet);
-
-Var
-  P : TParams;
-
-begin
-  inherited Create(ADataset);
-  If (ADataset<>Nil) then
-    begin
-    P:=TParams(GetObjectProp(ADataset,'Params',TParams));
-    if (P<>Nil) then
-      Params:=P;
-    end;  
-end;
-
-
-Procedure TMasterParamsDataLink.SetParams(AVAlue : TParams);  
-
-begin
-  FParams:=AValue;
-  If (AValue<>Nil) then
-    RefreshParamNames;
-end;
-
-Procedure TMasterParamsDataLink.RefreshParamNames; 
-
-Var
-  FN : String;
-  DS : TDataset;
-  F  : TField;
-  I : Integer;
-
-begin
-  FN:='';
-  DS:=Dataset;
-  If Assigned(FParams) then
-    begin
-    F:=Nil;
-    For I:=0 to FParams.Count-1 do
-      begin
-      If Assigned(DS) then
-        F:=DS.FindField(FParams[i].Name);
-      If (Not Assigned(DS)) or (F<>Nil) then
-        begin
-        If (FN<>'') then
-          FN:=FN+';';
-        FN:=FN+FParams[i].Name; 
-        end;
-      end;
-    end;
-  FieldNames:=FN;  
-end;
-
-Procedure TMasterParamsDataLink.CopyParamsFromMaster(CopyBound : Boolean);
-
-begin
-  if Assigned(FParams) then
-    FParams.CopyParamValuesFromDataset(Dataset,CopyBound);
-end;
-
-Procedure TMasterParamsDataLink.DoMasterDisable; 
-
-begin
-  Inherited;
-  If Assigned(DetailDataset) and DetailDataset.Active then
-    DetailDataset.Close;
-end;
-
-Procedure TMasterParamsDataLink.DoMasterChange; 
-
-begin
-  Inherited;
-  if Assigned(Params) and Assigned(DetailDataset) and DetailDataset.Active then
-    begin
-    DetailDataSet.CheckBrowseMode;
-    DetailDataset.Close;
-    DetailDataset.Open;
-    end;
-end;
-
-{ ---------------------------------------------------------------------
-    TDatasource
-  ---------------------------------------------------------------------}
-
-Constructor TDataSource.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  FDatalinks := TList.Create;
-  FEnabled := True;
-  FAutoEdit := True;
-end;
-
-
-Destructor TDataSource.Destroy;
-
-begin
-  FOnStateCHange:=Nil;
-  Dataset:=Nil;
-  With FDataLinks do
-    While Count>0 do
-      TDatalink(Items[Count - 1]).DataSource:=Nil;
-  FDatalinks.Free;
-  inherited Destroy;
-end;
-
-
-Procedure TDatasource.Edit;
-
-begin
-  If (State=dsBrowse) and AutoEdit Then
-    Dataset.Edit;
-end;
-
-
-Function TDataSource.IsLinkedTo(ADataSet: TDataSet): Boolean;
-
-begin
-  Result:=False;
-end;
-
-
-procedure TDatasource.DistributeEvent(Event: TDataEvent; Info: Ptrint);
-
-
-Var
-  i : Longint;
-
-begin
-  With FDatalinks do
-    begin
-    For I:=0 to Count-1 do
-      With TDatalink(Items[i]) do
-        If Not VisualControl Then
-          DataEvent(Event,Info);
-    For I:=0 to Count-1 do
-      With TDatalink(Items[i]) do
-        If VisualControl Then
-          DataEvent(Event,Info);
-    end;
-end;
-
-procedure TDatasource.RegisterDataLink(DataLink: TDataLink);
-
-begin
-  FDatalinks.Add(DataLink);
-  if Assigned(DataSet) then
-    DataSet.RecalcBufListSize;
-end;
-
-
-procedure TDatasource.SetDataSet(ADataSet: TDataSet);
-begin
-  If FDataset<>Nil Then
-    Begin
-    FDataset.UnRegisterDataSource(Self);
-    FDataSet:=nil;
-    ProcessEvent(deUpdateState,0);
-    End;
-  If ADataset<>Nil Then
-    begin
-    ADataset.RegisterDatasource(Self);
-    FDataSet:=ADataset;
-    ProcessEvent(deUpdateState,0);
-    End;
-end;
-
-
-procedure TDatasource.SetEnabled(Value: Boolean);
-
-begin
-  FEnabled:=Value;
-end;
-
-
-Procedure TDatasource.DoDataChange (Info : Pointer);
-
-begin
-  If Assigned(OnDataChange) Then
-    OnDataChange(Self,TField(Info));
-end;
-
-Procedure TDatasource.DoStateChange;
-
-begin
-  If Assigned(OnStateChange) Then
-    OnStateChange(Self);
-end;
-
-
-Procedure TDatasource.DoUpdateData;
-
-begin
-  If Assigned(OnUpdateData) Then
-    OnUpdateData(Self);
-end;
-
-
-procedure TDatasource.UnregisterDataLink(DataLink: TDataLink);
-
-begin
-  FDatalinks.Remove(Datalink);
-  If Dataset<>Nil then
-    DataSet.RecalcBufListSize;
-  //Dataset.SetBufListSize(DataLink.BufferCount);
-end;
-
-
-procedure TDataSource.ProcessEvent(Event : TDataEvent; Info : Ptrint);
-
-Const
-    OnDataChangeEvents = [deRecordChange, deDataSetChange, deDataSetScroll,
-                          deLayoutChange,deUpdateState];
-
-Var
-  NeedDataChange : Boolean;
-  FLastState : TdataSetState;
-
-begin
-  // Special UpdateState handling.
-  If Event=deUpdateState then
-    begin
-    NeedDataChange:=(FState=dsInactive);
-    FLastState:=FState;
-    If Assigned(Dataset) then
-      FState:=Dataset.State
-    else
-      FState:=dsInactive;
-    // Don't do events if nothing changed.
-    If FState=FlastState then
-      exit;
-    end
-  else
-    NeedDataChange:=True;
-  DistributeEvent(Event,Info);
-  // Extra handlers
-  If Not (csDestroying in ComponentState) then
-    begin
-    If (Event=deUpdateState) then
-      DoStateChange;
-    If (Event in OnDataChangeEvents) and
-       NeedDataChange Then
-      DoDataChange(Nil);
-    If (Event = deFieldChange) Then
-      DoDataCHange(Pointer(Info));
-    If (Event=deUpdateRecord) then
-      DoUpdateData;
-    end;
- end;

+ 109 - 1
packages/fcl-db/src/export/Makefile

@@ -1467,165 +1467,220 @@ else
 TAROPT=vz
 TAREXT=.tar.gz
 endif
-override REQUIRE_PACKAGES=rtl 
+override REQUIRE_PACKAGES=rtl fcl-base
 ifeq ($(FULL_TARGET),i386-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_WINUNITS=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_WINUNITS=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_FCL-BASE=1
 endif
 ifdef REQUIRE_PACKAGES_RTL
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
@@ -1653,6 +1708,58 @@ ifdef UNITDIR_RTL
 override COMPILER_UNITDIR+=$(UNITDIR_RTL)
 endif
 endif
+ifdef REQUIRE_PACKAGES_FCL-BASE
+PACKAGEDIR_FCL-BASE:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /fcl-base/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_FCL-BASE),)
+ifneq ($(wildcard $(PACKAGEDIR_FCL-BASE)/units/$(TARGETSUFFIX)),)
+UNITDIR_FCL-BASE=$(PACKAGEDIR_FCL-BASE)/units/$(TARGETSUFFIX)
+else
+UNITDIR_FCL-BASE=$(PACKAGEDIR_FCL-BASE)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_FCL-BASE)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_FCL-BASE) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_FCL-BASE)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_FCL-BASE=
+UNITDIR_FCL-BASE:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /fcl-base/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_FCL-BASE),)
+UNITDIR_FCL-BASE:=$(firstword $(UNITDIR_FCL-BASE))
+else
+UNITDIR_FCL-BASE=
+endif
+endif
+ifdef UNITDIR_FCL-BASE
+override COMPILER_UNITDIR+=$(UNITDIR_FCL-BASE)
+endif
+endif
+ifdef REQUIRE_PACKAGES_WINUNITS
+PACKAGEDIR_WINUNITS:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /winunits/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_WINUNITS),)
+ifneq ($(wildcard $(PACKAGEDIR_WINUNITS)/units/$(TARGETSUFFIX)),)
+UNITDIR_WINUNITS=$(PACKAGEDIR_WINUNITS)/units/$(TARGETSUFFIX)
+else
+UNITDIR_WINUNITS=$(PACKAGEDIR_WINUNITS)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_WINUNITS)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_WINUNITS) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_WINUNITS)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_WINUNITS=
+UNITDIR_WINUNITS:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /winunits/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_WINUNITS),)
+UNITDIR_WINUNITS:=$(firstword $(UNITDIR_WINUNITS))
+else
+UNITDIR_WINUNITS=
+endif
+endif
+ifdef UNITDIR_WINUNITS
+override COMPILER_UNITDIR+=$(UNITDIR_WINUNITS)
+endif
+endif
 ifndef NOCPUDEF
 override FPCOPTDEF=$(CPU_TARGET)
 endif
@@ -2160,3 +2267,4 @@ makefiles: fpc_makefiles
 ifneq ($(wildcard fpcmake.loc),)
 include fpcmake.loc
 endif
+.NOTPARALLEL:

+ 4 - 0
packages/fcl-db/src/export/Makefile.fpc

@@ -9,6 +9,9 @@ main=fcl-db
 units=fpdbexport fpcsvexport fpfixedexport fpsqlexport fpsimplexmlexport fpsimplejsonexport fpdbfexport fptexexport fpstdexports 
 rsts=fpdbexport fpcsvexport fpfixedexport fpsqlexport fpsimplexmlexport fpsimplejsonexport fpdbfexport fptexexport fpstdexports
 
+[require]
+packages=fcl-base
+
 [compiler]
 options=-S2h
 
@@ -19,6 +22,7 @@ fpcpackage=y
 fpcdir=../../../..
 
 [rules]
+.NOTPARALLEL:
 #fpdbexport$(PPUEXT): fpdbexport$(PPEXT)
 
 #fpcsvexport$(PPUEXT): fpdbexport$(PPEXT)

+ 0 - 2883
packages/fcl-db/src/fields.inc

@@ -1,2883 +0,0 @@
-{
-    This file is part of the Free Pascal run time library.
-    Copyright (c) 1999-2000 by Michael Van Canneyt, member of the
-    Free Pascal development team
-
-    TFields and related components implementations.
-
-    See the file COPYING.FPC, included in this distribution,
-    for details about the copyright.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- **********************************************************************}
-{Procedure DumpMem (P : Pointer;Size : Longint);
-
-Var i : longint;
-
-begin
-  Write ('Memory dump : ');
-  For I:=0 to Size-1 do
-    Write (Pbyte(P)[i],' ');
-  Writeln;
-end;}
-
-{ ---------------------------------------------------------------------
-    TFieldDef
-  ---------------------------------------------------------------------}
-
-Constructor TFieldDef.Create(ACollection : TCollection);
-
-begin
-  Inherited create(ACollection);
-  FFieldNo:=Index+1;
-end;
-
-Constructor TFieldDef.Create(AOwner: TFieldDefs; const AName: string;
-      ADataType: TFieldType; ASize: Word; ARequired: Boolean; AFieldNo: Longint);
-
-begin
-{$ifdef dsdebug }
-  Writeln('TFieldDef.Create : ',Aname,'(',AFieldNo,')');
-{$endif}
-  Name:=Aname;
-  Inherited Create(AOwner);
-  FDatatype:=ADatatype;
-  FSize:=ASize;
-  FRequired:=ARequired;
-  FPrecision:=-1;
-  FFieldNo:=AFieldNo;
-end;
-
-Destructor TFieldDef.Destroy;
-
-begin
-  Inherited destroy;
-end;
-
-procedure TFieldDef.Assign(APersistent: TPersistent);
-var fd: TFieldDef;
-begin
-  fd := nil;
-  if APersistent is TFieldDef then
-    fd := APersistent as TFieldDef;
-  if Assigned(fd) then begin
-    Collection.BeginUpdate;
-    try
-      Name := fd.Name;
-      DataType := fd.DataType;
-      Size := fd.Size;
-      Precision := fd.Precision;
-      FRequired := fd.Required;
-    finally
-      Collection.EndUpdate;
-    end;
-  end else
-  inherited Assign(APersistent);
-end;
-
-Function TFieldDef.CreateField(AOwner: TComponent): TField;
-
-Var TheField : TFieldClass;
-
-begin
-{$ifdef dsdebug}
-  Writeln ('Creating field '+FNAME);
-{$endif dsdebug}
-  TheField:=GetFieldClass;
-  if TheField=Nil then
-    DatabaseErrorFmt(SUnknownFieldType,[FName]);
-  Result:=Thefield.Create(AOwner);
-  Try
-    Result.Size:=FSize;
-    Result.Required:=FRequired;
-    Result.FFieldName:=FName;
-    Result.FDisplayLabel:=DisplayName;
-    Result.FFieldNo:=Self.FieldNo;
-    Result.SetFieldType(DataType);
-    Result.FReadOnly:= (faReadOnly in Attributes);
-{$ifdef dsdebug}
-    Writeln ('TFieldDef.CReateField : Trying to set dataset');
-{$endif dsdebug}
-{$ifdef dsdebug}
-    Writeln ('TFieldDef.CReateField : Result Fieldno : ',Result.FieldNo,' Self : ',FieldNo);
-{$endif dsdebug}
-    Result.Dataset:=TFieldDefs(Collection).Dataset;
-    If Result is TFloatField then
-      TFloatField(Result).Precision:=FPrecision;
-  except
-    Result.Free;
-    Raise;
-  end;
-
-end;
-
-procedure TFieldDef.SetAttributes(AValue: TFieldAttributes);
-begin
-  FAttributes := AValue;
-  Changed(False);
-end;
-
-procedure TFieldDef.SetDataType(AValue: TFieldType);
-begin
-  FDataType := AValue;
-  Changed(False);
-end;
-
-procedure TFieldDef.SetPrecision(const AValue: Longint);
-begin
-  FPrecision := AValue;
-  Changed(False);
-end;
-
-procedure TFieldDef.SetSize(const AValue: Word);
-begin
-  FSize := AValue;
-  Changed(False);
-end;
-
-procedure TFieldDef.SetRequired(const AValue: Boolean);
-begin
-  FRequired := AValue;
-  Changed(False);
-end;
-
-Function TFieldDef.GetFieldClass : TFieldClass;
-
-begin
-  //!! Should be owner as tdataset but that doesn't work ??
-
-  If Assigned(Collection) And
-     (Collection is TFieldDefs) And
-     Assigned(TFieldDefs(Collection).Dataset) then
-    Result:=TFieldDefs(Collection).Dataset.GetFieldClass(FDataType)
-  else
-    Result:=Nil;
-end;
-
-{ ---------------------------------------------------------------------
-    TFieldDefs
-  ---------------------------------------------------------------------}
-
-{
-destructor TFieldDefs.Destroy;
-
-begin
-  FItems.Free;
-  // This will destroy all fielddefs since we own them...
-  Inherited Destroy;
-end;
-}
-
-procedure TFieldDefs.Add(const AName: string; ADataType: TFieldType);
-
-begin
-  Add(AName,ADatatype,0,False);
-end;
-
-procedure TFieldDefs.Add(const AName: string; ADataType: TFieldType; ASize : Word);
-
-begin
-  Add(AName,ADatatype,ASize,False);
-end;
-
-procedure TFieldDefs.Add(const AName: string; ADataType: TFieldType; ASize: Word;
-  ARequired: Boolean);
-
-begin
-  If Length(AName)=0 Then
-    DatabaseError(SNeedFieldName);
-  // the fielddef will register itself here as a owned component.
-  // fieldno is 1 based !
-  BeginUpdate;
-  try
-    TFieldDef.Create(Self,AName,ADataType,ASize,Arequired,Count+1);
-  finally
-    EndUpdate;
-  end;
-end;
-
-function TFieldDefs.GetItem(Index: Longint): TFieldDef;
-
-begin
-  Result := TFieldDef(inherited Items[Index]);
-end;
-
-procedure TFieldDefs.SetItem(Index: Longint; const AValue: TFieldDef);
-begin
-  inherited Items[Index] := AValue;
-end;
-
-constructor TFieldDefs.Create(ADataset: TDataset);
-begin
-  Inherited Create(ADataset, Owner, TFieldDef);
-end;
-
-procedure TFieldDefs.Assign(FieldDefs: TFieldDefs);
-
-Var I : longint;
-
-begin
-  Clear;
-  For i:=0 to FieldDefs.Count-1 do
-    With FieldDefs[i] do
-      Add(Name,DataType,Size,Required);
-end;
-
-{
-procedure TFieldDefs.Clear;
-
-Var I : longint;
-
-begin
-  For I:=FItems.Count-1 downto 0 do
-    TFieldDef(Fitems[i]).Free;
-  FItems.Clear;
-end;
-}
-
-procedure TFieldDefs.Update;
-
-begin
-  if not Updated then
-    begin
-    If Assigned(Dataset) then
-      DataSet.InitFieldDefs;
-    Updated := True;
-    end;
-end;
-
-Function TFieldDefs.AddFieldDef : TFieldDef;
-
-begin
-  Result:=TFieldDef.Create(Self,'',ftUnknown,0,False,Count+1);
-end;
-
-{ ---------------------------------------------------------------------
-    TField
-  ---------------------------------------------------------------------}
-
-Const
-  SBoolean = 'Boolean';
-  SDateTime = 'TDateTime';
-  SFloat = 'Float';
-  SInteger = 'Integer';
-  SLargeInt = 'LargeInt';
-  SVariant = 'Variant';
-  SString = 'String';
-
-constructor TField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  FVisible:=True;
-  FValidChars:=[#0..#255];
-
-  FProviderFlags := [pfInUpdate,pfInWhere];
-end;
-
-destructor TField.Destroy;
-
-begin
-  IF Assigned(FDataSet) then
-    begin
-    FDataSet.Active:=False;
-    if Assigned(FFields) then
-      FFields.Remove(Self);
-    end;
-  FLookupList.Free;
-  Inherited Destroy;
-end;
-
-function TField.AccessError(const TypeName: string): EDatabaseError;
-
-begin
-  Result:=EDatabaseError.CreateFmt(SinvalidTypeConversion,[TypeName,FFieldName]);
-end;
-
-procedure TField.Assign(Source: TPersistent);
-
-begin
-  if Source = nil then Clear
-  else if Source is TField then begin
-    Value := TField(Source).Value;
-  end else
-    inherited Assign(Source);
-end;
-
-procedure TField.AssignValue(const AValue: TVarRec);
-  procedure Error;
-  begin
-    DatabaseErrorFmt(SFieldValueError, [DisplayName]);
-  end;
-
-begin
-  with AValue do
-    case VType of
-      vtInteger:
-        AsInteger := VInteger;
-      vtBoolean:
-        AsBoolean := VBoolean;
-      vtChar:
-        AsString := VChar;
-      vtExtended:
-        AsFloat := VExtended^;
-      vtString:
-        AsString := VString^;
-      vtPointer:
-        if VPointer <> nil then Error;
-      vtPChar:
-        AsString := VPChar;
-      vtObject:
-        if (VObject = nil) or (VObject is TPersistent) then
-          Assign(TPersistent(VObject))
-        else
-          Error;
-      vtAnsiString:
-        AsString := string(VAnsiString);
-      vtCurrency:
-        AsCurrency := VCurrency^;
-      vtVariant:
-        if not VarIsClear(VVariant^) then Self.Value := VVariant^;
-      vtWideString:
-        AsWideString := WideString(VWideString);
-      vtInt64:
-        Self.Value := VInt64^;
-    else
-      Error;
-    end;
-end;
-
-procedure TField.Change;
-
-begin
-  If Assigned(FOnChange) Then
-    FOnChange(Self);
-end;
-
-procedure TField.CheckInactive;
-
-begin
-  If Assigned(FDataSet) then
-    FDataset.CheckInactive;
-end;
-
-procedure TField.Clear;
-
-begin
-  if FieldKind in [fkData, fkInternalCalc] then
-    SetData(Nil);
-end;
-
-procedure TField.DataChanged;
-
-begin
-  FDataset.DataEvent(deFieldChange,ptrint(Self));
-end;
-
-procedure TField.FocusControl;
-
-begin
-  FDataSet.DataEvent(deFocusControl,ptrint(@Self));
-end;
-
-procedure TField.FreeBuffers;
-
-begin
-  // Empty. Provided for backward compatibiliy;
-  // TDataset manages the buffers.
-end;
-
-function TField.GetAsBoolean: Boolean;
-
-begin
-  raise AccessError(SBoolean);
-end;
-
-function TField.GetAsDateTime: TDateTime;
-
-begin
-  raise AccessError(SdateTime);
-end;
-
-function TField.GetAsFloat: Double;
-
-begin
-  raise AccessError(SDateTime);
-end;
-
-function TField.GetAsLongint: Longint;
-
-begin
-  raise AccessError(SInteger);
-end;
-
-function TField.GetAsVariant: Variant;
-
-begin
-  raise AccessError(SVariant);
-end;
-
-
-function TField.GetAsInteger: Integer;
-
-begin
-  Result:=GetAsLongint;
-end;
-
-function TField.GetAsString: string;
-
-begin
-  Result := GetClassDesc;
-end;
-
-function TField.GetAsWideString: WideString;
-begin
-  Result := GetAsString;
-end;
-
-function TField.GetOldValue: Variant;
-
-var SaveState : TDatasetState;
-
-begin
-  SaveState := FDataset.State;
-  try
-    FDataset.SetTempState(dsOldValue);
-    Result := GetAsVariant;
-  finally
-    FDataset.RestoreState(SaveState);
-  end;
-end;
-
-function TField.GetNewValue: Variant;
-
-var SaveState : TDatasetState;
-
-begin
-  SaveState := FDataset.State;
-  try
-    FDataset.SetTempState(dsNewValue);
-    Result := GetAsVariant;
-  finally
-    FDataset.RestoreState(SaveState);
-  end;
-end;
-
-procedure TField.SetNewValue(const AValue: Variant);
-
-var SaveState : TDatasetState;
-
-begin
-  SaveState := FDataset.State;
-  try
-    FDataset.SetTempState(dsNewValue);
-    SetAsVariant(AValue);
-  finally
-    FDataset.RestoreState(SaveState);
-  end;
-end;
-
-function TField.GetCurValue: Variant;
-
-var SaveState : TDatasetState;
-
-begin
-  SaveState := FDataset.State;
-  try
-    FDataset.SetTempState(dsCurValue);
-    Result := GetAsVariant;
-  finally
-    FDataset.RestoreState(SaveState);
-  end;
-end;
-
-function TField.GetCanModify: Boolean;
-
-begin
-  Result:=Not ReadOnly;
-  If Result then
-    begin
-    Result:=Assigned(DataSet);
-    If Result then
-      Result:= DataSet.CanModify;
-    end;
-end;
-
-function TField.GetClassDesc: String;
-var ClassN : string;
-begin
-  ClassN := copy(ClassName,2,pos('Field',ClassName)-2);
-  if isNull then
-    result := '(' + LowerCase(ClassN) + ')'
-   else
-    result := '(' + UpperCase(ClassN) + ')';
-end;
-
-function TField.GetData(Buffer: Pointer): Boolean;
-
-begin
-  Result:=GetData(Buffer,True);
-end;
-
-function TField.GetData(Buffer: Pointer; NativeFormat : Boolean): Boolean;
-
-begin
-  IF FDataset=Nil then
-    DatabaseErrorFmt(SNoDataset,[FieldName]);
-  If FVAlidating then
-    begin
-    result:=Not(FValueBuffer=Nil);
-    If Result then
-      Move (FValueBuffer^,Buffer^ ,DataSize);
-    end
-  else
-    Result:=FDataset.GetFieldData(Self,Buffer,NativeFormat);
-end;
-
-function TField.GetDataSize: Word;
-
-begin
-  Result:=0;
-end;
-
-function TField.GetDefaultWidth: Longint;
-
-begin
-  Result:=10;
-end;
-
-function TField.GetDisplayName  : String;
-
-begin
-  If FDisplayLabel<>'' then
-    result:=FDisplayLabel
-  else
-    Result:=FFieldName;
-end;
-
-Function TField.IsDisplayStored : Boolean;
-
-begin
-  Result:=(DisplayLabel<>FieldName);
-end;
-
-function TField.GetLookupList: TLookupList;
-begin
-  if not Assigned(FLookupList) then
-    FLookupList := TLookupList.Create;
-  Result := FLookupList;
-end;
-
-procedure TField.CalcLookupValue;
-begin
-  if FLookupCache then
-    Value := LookupList.ValueOfKey(FDataSet.FieldValues[FKeyFields])
-  else if (FLookupDataSet <> nil) and FLookupDataSet.Active then
-    Value := FLookupDataSet.Lookup(FLookupKeyFields,
-      FDataSet.FieldValues[FKeyFields], FLookupResultField);
-end;
-
-function TField.getIndex : longint;
-
-begin
-  If Assigned(FDataset) then
-    Result:=FDataset.FFieldList.IndexOf(Self)
-  else
-    Result:=-1;
-end;
-
-function TField.GetAsLargeInt: LargeInt;
-begin
-  Raise AccessError(SLargeInt);
-end;
-
-function TField.GetAsCurrency: Currency;
-begin
-  Result := GetAsFloat;
-end;
-
-procedure TField.SetAlignment(const AValue: TAlignMent);
-begin
-  if FAlignment <> AValue then
-    begin
-    FAlignment := Avalue;
-    PropertyChanged(false);
-    end;
-end;
-
-procedure TField.SetIndex(const AValue: Integer);
-begin
-  if FFields <> nil then FFields.SetFieldIndex(Self, AValue)
-end;
-
-procedure TField.SetAsCurrency(AValue: Currency);
-begin
-  SetAsFloat(AValue);
-end;
-
-function TField.GetIsNull: Boolean;
-
-begin
-  Result:=Not(GetData (Nil));
-end;
-
-function TField.GetParentComponent: TComponent;
-
-begin
-  Result := DataSet;
-end;
-
-procedure TField.GetText(var AText: string; ADisplayText: Boolean);
-
-begin
-  AText:=GetAsString;
-end;
-
-function TField.HasParent: Boolean;
-
-begin
-  HasParent:=True;
-end;
-
-function TField.IsValidChar(InputChar: Char): Boolean;
-
-begin
-  // FValidChars must be set in Create.
-  Result:=InputChar in FValidChars;
-end;
-
-procedure TField.RefreshLookupList;
-var SaveActive: Boolean;
-begin
-  if (FLookupDataSet <> nil) And (FLookupKeyFields <> '') And
-     (FlookupResultField <> '') And (FKeyFields <> '') then begin
-    SaveActive := FLookupDataSet.Active;
-    with FLookupDataSet do
-    try
-      Active := True;
-      FFields.CheckFieldNames(FLookupKeyFields);
-      FieldByName(FLookupResultField);
-      LookupList.Clear;
-      DisableControls;
-      try
-        First;
-        while not Eof do begin
-          FLookupList.Add(FieldValues[FLookupKeyFields],
-            FieldValues[FLookupResultField]);
-          Next;
-        end;
-      finally
-        EnableControls;
-      end;
-    finally
-      Active := SaveActive;
-    end;
-  end;
-end;
-
-procedure TField.Notification(AComponent: TComponent; Operation: TOperation);
-
-begin
-  Inherited Notification(AComponent,Operation);
-  if (Operation = opRemove) and (AComponent = FLookupDataSet) then
-    FLookupDataSet := nil;
-end;
-
-procedure TField.PropertyChanged(LayoutAffected: Boolean);
-
-begin
-  If (FDataset<>Nil) and (FDataset.Active) then
-    If LayoutAffected then
-      FDataset.DataEvent(deLayoutChange,0)
-    else
-      FDataset.DataEvent(deDatasetchange,0);
-end;
-
-procedure TField.ReadState(Reader: TReader);
-
-begin
-  inherited ReadState(Reader);
-  if Reader.Parent is TDataSet then
-    DataSet := TDataSet(Reader.Parent);
-end;
-
-procedure TField.SetAsBoolean(AValue: Boolean);
-
-begin
-  Raise AccessError(SBoolean);
-end;
-
-procedure TField.SetAsDateTime(AValue: TDateTime);
-
-begin
-  Raise AccessError(SDateTime);
-end;
-
-procedure TField.SetAsFloat(AValue: Double);
-
-begin
-  Raise AccessError(SFloat);
-end;
-
-procedure TField.SetAsVariant(AValue: Variant);
-
-begin
-  if VarIsNull(AValue) then
-    Clear
-  else
-    try
-      SetVarValue(AValue);
-    except
-      on EVariantError do DatabaseErrorFmt(SFieldValueError, [DisplayName]);
-    end;
-end;
-
-
-procedure TField.SetAsLongint(AValue: Longint);
-
-begin
-  Raise AccessError(SInteger);
-end;
-
-procedure TField.SetAsInteger(AValue: Integer);
-
-begin
-  SetAsLongint(AValue);
-end;
-
-procedure TField.SetAsLargeint(AValue: Largeint);
-begin
-  Raise AccessError(SLargeInt);
-end;
-
-procedure TField.SetAsString(const AValue: string);
-
-begin
-  Raise AccessError(SString);
-end;
-
-procedure TField.SetAsWideString(const aValue: WideString);
-begin
-  SetAsString(aValue);
-end;
-
-
-procedure TField.SetData(Buffer: Pointer);
-
-begin
- SetData(Buffer,True);
-end;
-
-procedure TField.SetData(Buffer: Pointer; NativeFormat : Boolean);
-
-begin
-  If Not Assigned(FDataset) then
-    EDatabaseError.CreateFmt(SNoDataset,[FieldName]);
-  FDataSet.SetFieldData(Self,Buffer, NativeFormat);
-end;
-
-Procedure TField.SetDataset (AValue : TDataset);
-
-begin
-{$ifdef dsdebug}
-  Writeln ('Setting dataset');
-{$endif}
-  If AValue=FDataset then exit;
-  If Assigned(FDataset) Then
-    begin
-    FDataset.CheckInactive;
-    FDataset.FFieldList.Remove(Self);
-    end;
-  If Assigned(AValue) then
-    begin
-    AValue.CheckInactive;
-    AValue.FFieldList.Add(Self);
-    end;
-  FDataset:=AValue;
-end;
-
-procedure TField.SetDataType(AValue: TFieldType);
-
-begin
-  FDataType := AValue;
-end;
-
-procedure TField.SetFieldType(AValue: TFieldType);
-
-begin
-  { empty }
-end;
-
-procedure TField.SetParentComponent(AParent: TComponent);
-
-begin
-  if not (csLoading in ComponentState) then
-    DataSet := AParent as TDataSet;
-end;
-
-procedure TField.SetSize(AValue: Word);
-
-begin
-  CheckInactive;
-  CheckTypeSize(AValue);
-  FSize:=AValue;
-end;
-
-procedure TField.SetText(const AValue: string);
-
-begin
-  AsString:=AValue;
-end;
-
-procedure TField.SetVarValue(const AValue: Variant);
-begin
-  Raise AccessError(SVariant);
-end;
-
-procedure TField.Validate(Buffer: Pointer);
-
-begin
-  If assigned(OnValidate) Then
-    begin
-    FValueBuffer:=Buffer;
-    FValidating:=True;
-    Try
-      OnValidate(Self);
-    finally
-      FValidating:=False;
-    end;
-    end;
-end;
-
-class function Tfield.IsBlob: Boolean;
-
-begin
-  Result:=False;
-end;
-
-class procedure TField.CheckTypeSize(AValue: Longint);
-
-begin
-  If (AValue<>0) and Not IsBlob Then
-    DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
-end;
-
-// TField private methods
-
-procedure TField.SetEditText(const AValue: string);
-begin
-  if Assigned(OnSetText) then
-    OnSetText(Self, AValue)
-  else
-    SetText(AValue);
-end;
-
-function TField.GetEditText: String;
-begin
-  SetLength(Result, 0);
-  if Assigned(OnGetText) then
-    OnGetText(Self, Result, False)
-  else
-    GetText(Result, False);
-end;
-
-function TField.GetDisplayText: String;
-begin
-  SetLength(Result, 0);
-  if Assigned(OnGetText) then
-    OnGetText(Self, Result, True)
-  else
-    GetText(Result, True);
-end;
-
-procedure TField.SetDisplayLabel(const AValue: string);
-begin
-  if FDisplayLabel<>Avalue then
-    begin
-    FDisplayLabel:=Avalue;
-    PropertyChanged(true);
-    end;
-end;
-
-procedure TField.SetDisplayWidth(const AValue: Longint);
-begin
-  if FDisplayWidth<>AValue then
-    begin
-    FDisplayWidth:=AValue;
-    PropertyChanged(True);
-    end;
-end;
-
-function TField.GetDisplayWidth: integer;
-begin
-  if FDisplayWidth=0 then
-    result:=GetDefaultWidth
-  else
-    result:=FDisplayWidth;
-end;
-
-procedure TField.SetReadOnly(const AValue: Boolean);
-begin
-  if (FReadOnly<>Avalue) then
-    begin
-    FReadOnly:=AValue;
-    PropertyChanged(True);
-    end;
-end;
-
-procedure TField.SetVisible(const AValue: Boolean);
-begin
-  if FVisible<>Avalue then
-    begin
-    FVisible:=AValue;
-    PropertyChanged(True);
-    end;
-end;
-
-
-{ ---------------------------------------------------------------------
-    TStringField
-  ---------------------------------------------------------------------}
-
-
-constructor TStringField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  SetDataType(ftString);
-  FFixedChar := False;
-  FTransliterate := False;
-  FSize:=20;
-end;
-
-class procedure TStringField.CheckTypeSize(AValue: Longint);
-
-begin
-// A size of 0 is allowed, since for example Firebird allows
-// a query like: 'select '' as fieldname from table' which
-// results in a string with size 0.
-  If (AValue<0) or (AValue>dsMaxStringSize) Then
-    databaseErrorFmt(SInvalidFieldSize,[AValue])
-end;
-
-function TStringField.GetAsBoolean: Boolean;
-
-Var S : String;
-
-begin
-  S:=GetAsString;
-  result := (Length(S)>0) and (Upcase(S[1]) in ['T',YesNoChars[True]]);
-end;
-
-function TStringField.GetAsDateTime: TDateTime;
-
-begin
-  Result:=StrToDateTime(GetAsString);
-end;
-
-function TStringField.GetAsFloat: Double;
-
-begin
-  Result:=StrToFloat(GetAsString);
-end;
-
-function TStringField.GetAsLongint: Longint;
-
-begin
-  Result:=StrToInt(GetAsString);
-end;
-
-function TStringField.GetAsString: string;
-
-begin
-  If Not GetValue(Result) then
-    Result:='';
-end;
-
-function TStringField.GetAsVariant: Variant;
-
-Var s : string;
-
-begin
-  If GetValue(s) then
-    Result:=s
-  else
-    Result:=Null;
-end;
-
-
-function TStringField.GetDataSize: Word;
-
-begin
-  Result:=Size+1;
-end;
-
-function TStringField.GetDefaultWidth: Longint;
-
-begin
-  result:=Size;
-end;
-
-Procedure TStringField.GetText(var AText: string; ADisplayText: Boolean);
-
-begin
-    AText:=GetAsString;
-end;
-
-function TStringField.GetValue(var AValue: string): Boolean;
-
-Var Buf, TBuf : TStringFieldBuffer;
-
-begin
-  Result:=GetData(@Buf);
-  If Result then
-    begin
-    if transliterate then
-      begin
-      DataSet.Translate(Buf,TBuf,False);
-      AValue:=TBuf;
-      end
-    else
-      AValue:=Buf
-    end
-end;
-
-procedure TStringField.SetAsBoolean(AValue: Boolean);
-
-begin
-  If AValue Then
-    SetAsString('T')
-  else
-    SetAsString('F');
-end;
-
-procedure TStringField.SetAsDateTime(AValue: TDateTime);
-
-begin
-  SetAsString(DateTimeToStr(AValue));
-end;
-
-procedure TStringField.SetAsFloat(AValue: Double);
-
-begin
-  SetAsString(FloatToStr(AValue));
-end;
-
-procedure TStringField.SetAsLongint(AValue: Longint);
-
-begin
-  SetAsString(intToStr(AValue));
-end;
-
-procedure TStringField.SetAsString(const AValue: string);
-
-var Buf      : TStringFieldBuffer;
-
-begin
-  IF Length(AValue)=0 then
-    begin
-    Buf := #0;
-    SetData(@buf);
-    end
-  else if FTransliterate then
-    begin
-    DataSet.Translate(@AValue[1],Buf,True);
-    Buf[DataSize-1] := #0;
-    SetData(@buf);
-    end
-  else
-    begin
-    // The data is copied into the buffer, since some TDataset descendents copy
-    // the whole buffer-length in SetData. (See bug 8477)
-    Buf := AValue;
-    // If length(AValue) > Datasize the buffer isn't terminated properly
-    Buf[DataSize-1] := #0;
-    SetData(@Buf);
-    end;
-end;
-
-procedure TStringField.SetVarValue(const AValue: Variant);
-begin
-  SetAsString(AValue);
-end;
-
-{ ---------------------------------------------------------------------
-    TWideStringField
-  ---------------------------------------------------------------------}
-
-class procedure TWideStringField.CheckTypeSize(aValue: Integer);
-begin
-  if aValue <= 0 then
-    DatabaseErrorFmt(SInvalidFieldSize,[aValue]);
-end;
-
-constructor TWideStringField.Create(AOwner: TComponent);
-begin
-  inherited Create(AOwner);
-  SetDataType(ftWideString);
-end;
-
-function TWideStringField.GetValue(var aValue: WideString): Boolean;
-var
-  FixBuffer : array[0..dsMaxStringSize div 2] of WideChar;
-  DynBuffer : array of WideChar;
-  Buffer    : PWideChar;
-begin
-  if DataSize <= dsMaxStringSize then begin
-    Result := GetData(@FixBuffer, False);
-    aValue := FixBuffer;
-  end else begin
-    SetLength(DynBuffer, Succ(Size));
-    Buffer := PWideChar(DynBuffer);
-    Result := GetData(Buffer, False);
-    if Result then
-      aValue := Buffer;
-  end;
-end;
-
-function TWideStringField.GetAsString: string;
-begin
-  Result := GetAsWideString;
-end;
-
-procedure TWideStringField.SetAsString(const aValue: string);
-begin
-  SetAsWideString(aValue);
-end;
-
-function TWideStringField.GetAsVariant: Variant;
-var
-  ws: WideString;
-begin
-  if GetValue(ws) then
-    Result := ws
-  else
-    Result := Null;
-end;
-
-procedure TWideStringField.SetVarValue(const aValue: Variant);
-begin
-  SetAsWideString(aValue);
-end;
-
-function TWideStringField.GetAsWideString: WideString;
-begin
-  if not GetValue(Result) then
-    Result := '';
-end;
-
-procedure TWideStringField.SetAsWideString(const aValue: WideString);
-const
-  NullWideChar : WideChar = #0;
-var
-  Buffer : PWideChar;
-begin
-  if Length(aValue)>0 then
-    Buffer := PWideChar(@aValue[1])
-  else
-    Buffer := @NullWideChar;
-  SetData(Buffer, False);
-end;
-
-function TWideStringField.GetDataSize: Word;
-begin
-  Result :=
-    (Size + 1) * 2;
-end;
-
-
-{ ---------------------------------------------------------------------
-    TNumericField
-  ---------------------------------------------------------------------}
-
-
-constructor TNumericField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  AlignMent:=taRightJustify;
-end;
-
-procedure TNumericField.RangeError(AValue, Min, Max: Double);
-
-begin
-  DatabaseErrorFMT(SRangeError,[AValue,Min,Max,FieldName]);
-end;
-
-procedure TNumericField.SetDisplayFormat(const AValue: string);
-
-begin
- If FDisplayFormat<>AValue then
-   begin
-   FDisplayFormat:=AValue;
-   PropertyChanged(True);
-   end;
-end;
-
-procedure TNumericField.SetEditFormat(const AValue: string);
-
-begin
-  If FEDitFormat<>AValue then
-    begin
-    FEDitFormat:=AVAlue;
-    PropertyChanged(True);
-    end;
-end;
-
-{ ---------------------------------------------------------------------
-    TLongintField
-  ---------------------------------------------------------------------}
-
-
-constructor TLongintField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  SetDatatype(ftinteger);
-  FMinRange:=Low(LongInt);
-  FMaxRange:=High(LongInt);
-  FValidchars:=['+','-','0'..'9'];
-end;
-
-function TLongintField.GetAsFloat: Double;
-
-begin
-  Result:=GetAsLongint;
-end;
-
-function TLongintField.GetAsLongint: Longint;
-
-begin
-  If Not GetValue(Result) then
-    Result:=0;
-end;
-
-function TLongintField.GetAsVariant: Variant;
-
-Var L : Longint;
-
-begin
-  If GetValue(L) then
-    Result:=L
-  else
-    Result:=Null;
-end;
-
-function TLongintField.GetAsString: string;
-
-Var L : Longint;
-
-begin
-  If GetValue(L) then
-    Result:=IntTostr(L)
-  else
-    Result:='';
-end;
-
-function TLongintField.GetDataSize: Word;
-
-begin
-  Result:=SizeOf(Longint);
-end;
-
-procedure TLongintField.GetText(var AText: string; ADisplayText: Boolean);
-
-var l : longint;
-    fmt : string;
-
-begin
-  Atext:='';
-  If Not GetValue(l) then exit;
-  If ADisplayText or (FEditFormat='') then
-    fmt:=FDisplayFormat
-  else
-    fmt:=FEditFormat;
-  If length(fmt)<>0 then
-    AText:=FormatFloat(fmt,L)
-  else
-    Str(L,AText);
-end;
-
-function TLongintField.GetValue(var AValue: Longint): Boolean;
-
-Var L : Longint;
-    P : PLongint;
-
-begin
-  P:=@L;
-  Result:=GetData(P);
-  If Result then
-    Case Datatype of
-      ftInteger,ftautoinc  : AValue:=Plongint(P)^;
-      ftword               : Avalue:=Pword(P)^;
-      ftsmallint           : AValue:=PSmallint(P)^;
-    end;
-end;
-
-procedure TLongintField.SetAsFloat(AValue: Double);
-
-begin
-  SetAsLongint(Round(Avalue));
-end;
-
-procedure TLongintField.SetAsLongint(AValue: Longint);
-
-begin
-  If CheckRange(AValue) then
-    SetData(@AValue)
-  else
-    RangeError(Avalue,FMinrange,FMaxRange);
-end;
-
-procedure TLongintField.SetVarValue(const AValue: Variant);
-begin
-  SetAsLongint(AValue);
-end;
-
-procedure TLongintField.SetAsString(const AValue: string);
-
-Var L,Code : longint;
-
-begin
-  If length(AValue)=0 then
-    Clear
-  else
-    begin
-    Val(AVAlue,L,Code);
-    If Code=0 then
-      SetAsLongint(L)
-    else
-      DatabaseErrorFMT(SNotAnInteger,[Avalue]);
-    end;
-end;
-
-Function TLongintField.CheckRange(AValue : longint) : Boolean;
-
-begin
-  result := true;
-  if (FMaxValue=0) then
-    begin
-    if (AValue>FMaxRange) Then result := false;
-    end
-  else
-    if AValue>FMaxValue then result := false;
-
-  if (FMinValue=0) then
-    begin
-    if (AValue<FMinRange) Then result := false;
-    end
-  else
-    if AValue<FMinValue then result := false;
-end;
-
-Procedure TLongintField.SetMaxValue (AValue : longint);
-
-begin
-  If (AValue>=FMinRange) and (AValue<=FMaxRange) then
-    FMaxValue:=AValue
-  else
-    RangeError(AValue,FMinRange,FMaxRange);
-end;
-
-Procedure TLongintField.SetMinValue (AValue : longint);
-
-begin
-  If (AValue>=FMinRange) and (AValue<=FMaxRange) then
-    FMinValue:=AValue
-  else
-    RangeError(AValue,FMinRange,FMaxRange);
-end;
-
-{ ---------------------------------------------------------------------
-    TLargeintField
-  ---------------------------------------------------------------------}
-
-
-constructor TLargeintField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  SetDatatype(ftLargeint);
-  FMinRange:=Low(Largeint);
-  FMaxRange:=High(Largeint);
-  FValidchars:=['+','-','0'..'9'];
-end;
-
-function TLargeintField.GetAsFloat: Double;
-
-begin
-  Result:=GetAsLargeint;
-end;
-
-function TLargeintField.GetAsLargeint: Largeint;
-
-begin
-  If Not GetValue(Result) then
-    Result:=0;
-end;
-
-function TLargeIntField.GetAsVariant: Variant;
-
-Var L : Largeint;
-
-begin
-  If GetValue(L) then
-    Result:=L
-  else
-    Result:=Null;
-end;
-
-function TLargeintField.GetAsLongint: Longint;
-
-begin
-  Result:=GetAsLargeint;
-end;
-
-function TLargeintField.GetAsString: string;
-
-Var L : Largeint;
-
-begin
-  If GetValue(L) then
-    Result:=IntTostr(L)
-  else
-    Result:='';
-end;
-
-function TLargeintField.GetDataSize: Word;
-
-begin
-  Result:=SizeOf(Largeint);
-end;
-
-procedure TLargeintField.GetText(var AText: string; ADisplayText: Boolean);
-
-var l : largeint;
-    fmt : string;
-
-begin
-  Atext:='';
-  If Not GetValue(l) then exit;
-  If ADisplayText or (FEditFormat='') then
-    fmt:=FDisplayFormat
-  else
-    fmt:=FEditFormat;
-  If length(fmt)<>0 then
-    AText:=FormatFloat(fmt,L)
-  else
-    Str(L,AText);
-end;
-
-function TLargeintField.GetValue(var AValue: Largeint): Boolean;
-
-type
-  PLargeint = ^Largeint;
-
-Var P : PLargeint;
-
-begin
-  P:=@AValue;
-  Result:=GetData(P);
-end;
-
-procedure TLargeintField.SetAsFloat(AValue: Double);
-
-begin
-  SetAsLargeint(Round(Avalue));
-end;
-
-procedure TLargeintField.SetAsLargeint(AValue: Largeint);
-
-begin
-  If CheckRange(AValue) then
-    SetData(@AValue)
-  else
-    RangeError(Avalue,FMinrange,FMaxRange);
-end;
-
-procedure TLargeintField.SetAsLongint(AValue: Longint);
-
-begin
-  SetAsLargeint(Avalue);
-end;
-
-procedure TLargeintField.SetAsString(const AValue: string);
-
-Var L     : largeint;
-    code  : longint;
-
-begin
-  If length(AValue)=0 then
-    Clear
-  else
-    begin
-    Val(AVAlue,L,Code);
-    If Code=0 then
-      SetAsLargeint(L)
-    else
-      DatabaseErrorFMT(SNotAnInteger,[Avalue]);
-    end;
-end;
-
-procedure TLargeintField.SetVarValue(const AValue: Variant);
-begin
-  SetAsLargeint(AValue);
-end;
-
-Function TLargeintField.CheckRange(AValue : largeint) : Boolean;
-
-begin
-  result := true;
-  if (FMaxValue=0) then
-    begin
-    if (AValue>FMaxRange) Then result := false;
-    end
-  else
-    if AValue>FMaxValue then result := false;
-
-  if (FMinValue=0) then
-    begin
-    if (AValue<FMinRange) Then result := false;
-    end
-  else
-    if AValue<FMinValue then result := false;
-end;
-
-Procedure TLargeintField.SetMaxValue (AValue : largeint);
-
-begin
-  If (AValue>=FMinRange) and (AValue<=FMaxRange) then
-    FMaxValue:=AValue
-  else
-    RangeError(AValue,FMinRange,FMaxRange);
-end;
-
-Procedure TLargeintField.SetMinValue (AValue : largeint);
-
-begin
-  If (AValue>=FMinRange) and (AValue<=FMaxRange) then
-    FMinValue:=AValue
-  else
-    RangeError(AValue,FMinRange,FMaxRange);
-end;
-
-{ TSmallintField }
-
-function TSmallintField.GetDataSize: Word;
-
-begin
-  Result:=SizeOf(SmallInt);
-end;
-
-constructor TSmallintField.Create(AOwner: TComponent);
-
-begin
-  inherited Create(AOwner);
-  SetDataType(ftSmallInt);
-  FMinRange:=-32768;
-  FMaxRange:=32767;
-end;
-
-
-{ TWordField }
-
-function TWordField.GetDataSize: Word;
-
-begin
-  Result:=SizeOf(Word);
-end;
-
-constructor TWordField.Create(AOwner: TComponent);
-
-begin
-  inherited Create(AOwner);
-  SetDataType(ftWord);
-  FMinRange:=0;
-  FMaxRange:=65535;
-  FValidchars:=['+','0'..'9'];
-end;
-
-{ TAutoIncField }
-
-constructor TAutoIncField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOWner);
-  SetDataType(ftAutoInc);
-  FReadOnly:=True;
-end;
-
-Procedure TAutoIncField.SetAsLongint(AValue : Longint);
-
-begin
-  DataBaseError(SCantSetAutoIncfields);
-end;
-
-{ TFloatField }
-
-procedure TFloatField.SetCurrency(const AValue: Boolean);
-begin
-  if FCurrency=AValue then exit;
-  FCurrency:=AValue;
-end;
-
-function TFloatField.GetAsFloat: Double;
-
-begin
-  If Not GetData(@Result) Then
-    Result:=0.0;
-end;
-
-function TFloatField.GetAsVariant: Variant;
-
-Var f : Double;
-
-begin
-  If GetData(@f) then
-    Result := f
-  else
-    Result:=Null;
-end;
-
-function TFloatField.GetAsLongint: Longint;
-
-begin
-  Result:=Round(GetAsFloat);
-end;
-
-function TFloatField.GetAsString: string;
-
-Var R : Double;
-
-begin
-  If GetData(@R) then
-    Result:=FloatToStr(R)
-  else
-    Result:='';
-end;
-
-function TFloatField.GetDataSize: Word;
-
-begin
-  Result:=SizeOf(Double);
-end;
-
-procedure TFloatField.GetText(var TheText: string; ADisplayText: Boolean);
-
-Var
-    fmt : string;
-    E : Double;
-    Digits : integer;
-    ff: TFloatFormat;
-
-begin
-  TheText:='';
-  If Not GetData(@E) then exit;
-  If ADisplayText or (Length(FEditFormat) = 0) Then
-    Fmt:=FDisplayFormat
-  else
-    Fmt:=FEditFormat;
-    
-  Digits := 0;
-  if not FCurrency then
-    ff := ffGeneral
-  else
-    begin
-    Digits := CurrencyDecimals;
-    if ADisplayText then
-      ff := ffCurrency
-    else
-      ff := ffFixed;
-    end;
-
-
-  If fmt<>'' then
-    TheText:=FormatFloat(fmt,E)
-  else
-    TheText:=FloatToStrF(E,ff,FPrecision,Digits);
-end;
-
-procedure TFloatField.SetAsFloat(AValue: Double);
-
-begin
-  If CheckRange(AValue) then
-    SetData(@Avalue)
-  else
-    RangeError(AValue,FMinValue,FMaxValue);
-end;
-
-procedure TFloatField.SetAsLongint(AValue: Longint);
-
-begin
-  SetAsFloat(Avalue);
-end;
-
-procedure TFloatField.SetAsString(const AValue: string);
-
-Var R : Double;
-
-begin
-  If (AValue='') then
-    Clear
-  else  
-    try
-      R := StrToFloat(AValue);
-      SetAsFloat(R);
-    except
-      DatabaseErrorFmt(SNotAFloat, [AValue]);
-    end;
-end;
-
-procedure TFloatField.SetVarValue(const AValue: Variant);
-begin
-  SetAsFloat(Avalue);
-end;
-
-constructor TFloatField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  SetDatatype(ftfloat);
-  FPrecision:=15;
-  FValidChars := [DecimalSeparator, '+', '-', '0'..'9', 'E', 'e'];
-end;
-
-Function TFloatField.CheckRange(AValue : Double) : Boolean;
-
-begin
-  If (FMinValue<>0) or (FmaxValue<>0) then
-    Result:=(AValue>=FMinValue) and (AVAlue<=FMAxValue)
-  else
-    Result:=True;
-end;
-
-{ TCurrencyField }
-
-Constructor TCurrencyField.Create(AOwner: TComponent);
-
-begin
-  inherited Create(AOwner);
-  SetDataType(ftCurrency);
-  Currency := True;
-end;
-
-{ TBooleanField }
-
-function TBooleanField.GetAsBoolean: Boolean;
-
-var b : wordbool;
-
-begin
-  If GetData(@b) then
-    result := b
-  else
-    Result:=False;
-end;
-
-function TBooleanField.GetAsVariant: Variant;
-
-Var b : wordbool;
-
-begin
-  If GetData(@b) then
-    Result := b
-  else
-    Result:=Null;
-end;
-
-function TBooleanField.GetAsString: string;
-
-Var B : wordbool;
-
-begin
-  If Getdata(@B) then
-    Result:=FDisplays[False,B]
-  else
-    result:='';
-end;
-
-function TBooleanField.GetDataSize: Word;
-
-begin
-  Result:=SizeOf(wordBool);
-end;
-
-function TBooleanField.GetDefaultWidth: Longint;
-
-begin
-  Result:=Length(FDisplays[false,false]);
-  If Result<Length(FDisplays[false,True]) then
-    Result:=Length(FDisplays[false,True]);
-end;
-
-procedure TBooleanField.SetAsBoolean(AValue: Boolean);
-
-var b : wordbool;
-
-begin
-  b := AValue;
-  SetData(@b);
-end;
-
-procedure TBooleanField.SetAsString(const AValue: string);
-
-Var Temp : string;
-
-begin
-  Temp:=UpperCase(AValue);
-  if Temp='' then
-    Clear
-  else if pos(Temp, FDisplays[True,True])=1 then
-    SetAsBoolean(True)
-  else if pos(Temp, FDisplays[True,False])=1 then
-    SetAsBoolean(False)
-  else
-    DatabaseErrorFmt(SNotABoolean,[AValue]);
-end;
-
-procedure TBooleanField.SetVarValue(const AValue: Variant);
-begin
-  SetAsBoolean(AValue);
-end;
-
-constructor TBooleanField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  SetDataType(ftBoolean);
-  DisplayValues:='True;False';
-end;
-
-Procedure TBooleanField.SetDisplayValues(AValue : String);
-
-Var I : longint;
-
-begin
-  If FDisplayValues<>AValue then
-    begin
-    I:=Pos(';',AValue);
-    If (I<2) or (I=Length(AValue)) then
-      DatabaseErrorFmt(SInvalidDisplayValues,[AValue]);
-    FdisplayValues:=AValue;
-    // Store display values and their uppercase equivalents;
-    FDisplays[False,True]:=Copy(AValue,1,I-1);
-    FDisplays[True,True]:=UpperCase(FDisplays[False,True]);
-    FDisplays[False,False]:=Copy(AValue,I+1,Length(AValue)-i);
-    FDisplays[True,False]:=UpperCase(FDisplays[False,False]);
-    PropertyChanged(True);
-    end;
-end;
-
-{ TDateTimeField }
-
-procedure TDateTimeField.SetDisplayFormat(const AValue: string);
-begin
-  if FDisplayFormat<>AValue then begin
-    FDisplayFormat:=AValue;
-    PropertyChanged(True);
-  end;
-end;
-
-function TDateTimeField.GetAsDateTime: TDateTime;
-
-begin
-  If Not GetData(@Result,False) then
-    Result:=0;
-end;
-
-procedure TDateTimeField.SetVarValue(const AValue: Variant);
-begin
-  SetAsDateTime(AValue);
-end;
-
-function TDateTimeField.GetAsVariant: Variant;
-
-Var d : tDateTime;
-
-begin
-  If Getdata(@d,False) then
-    Result := d
-  else
-    Result:=Null;
-end;
-
-function TDateTimeField.GetAsFloat: Double;
-
-begin
-  Result:=GetAsdateTime;
-end;
-
-
-function TDateTimeField.GetAsString: string;
-
-begin
-  GetText(Result,False);
-end;
-
-
-function TDateTimeField.GetDataSize: Word;
-
-begin
-  Result:=SizeOf(TDateTime);
-end;
-
-
-procedure TDateTimeField.GetText(var TheText: string; ADisplayText: Boolean);
-
-Var R : TDateTime;
-    F : String;
-
-begin
-  If Not Getdata(@R,False) then
-    TheText:=''
-  else
-    begin
-    If (ADisplayText) and (Length(FDisplayFormat)<>0) then
-      F:=FDisplayFormat
-    else
-      Case DataType of
-       ftTime : F:=ShortTimeFormat;
-       ftDate : F:=ShortDateFormat;
-      else
-       F:='c'
-      end;
-    TheText:=FormatDateTime(F,R);
-    end;
-end;
-
-
-procedure TDateTimeField.SetAsDateTime(AValue: TDateTime);
-
-begin
-  SetData(@Avalue,False);
-end;
-
-
-procedure TDateTimeField.SetAsFloat(AValue: Double);
-
-begin
-  SetAsDateTime(AValue);
-end;
-
-
-procedure TDateTimeField.SetAsString(const AValue: string);
-
-Var R : TDateTime;
-
-begin
-  R:=StrToDateTime(AVAlue);
-  SetData(@R,False);
-end;
-
-
-constructor TDateTimeField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  SetDataType(ftDateTime);
-end;
-
-
-{ TDateField }
-
-constructor TDateField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  SetDataType(ftDate);
-end;
-
-
-{ TTimeField }
-
-constructor TTimeField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  SetDataType(ftTime);
-end;
-
-procedure TTimeField.SetAsString(const AValue: string);
-Var R : TDateTime;
-begin
-  R:=StrToTime(AVAlue);
-  SetData(@R);
-end;
-
-
-
-{ TBinaryField }
-
-class procedure TBinaryField.CheckTypeSize(AValue: Longint);
-
-begin
-  // Just check for really invalid stuff; actual size is
-  // dependent on the record...
-  If AValue<1 then
-    DatabaseErrorfmt(SInvalidFieldSize,[Avalue]);
-end;
-
-
-function TBinaryField.GetAsString: string;
-
-begin
-  Setlength(Result,DataSize);
-  GetData(Pointer(Result));
-end;
-
-
-procedure TBinaryField.GetText(var TheText: string; ADisplayText: Boolean);
-
-begin
-  TheText:=GetAsString;
-end;
-
-
-procedure TBinaryField.SetAsString(const AValue: string);
-
-Var Buf : PChar;
-    Allocated : Boolean;
-
-begin
-  Allocated:=False;
-  If Length(AVAlue)=DataSize then
-    Buf:=PChar(Avalue)
-  else
-    begin
-    GetMem(Buf,DataSize);
-    Move(Pchar(Avalue)[0],Buf^,DataSize);
-    Allocated:=True;
-    end;
-  SetData(Buf);
-  If Allocated then
-    FreeMem(Buf,DataSize);
-end;
-
-
-procedure TBinaryField.SetText(const AValue: string);
-
-begin
-  SetAsString(Avalue);
-end;
-
-procedure TBinaryField.SetVarValue(const AValue: Variant);
-begin
-  SetAsString(Avalue);
-end;
-
-
-constructor TBinaryField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-end;
-
-
-
-{ TBytesField }
-
-function TBytesField.GetDataSize: Word;
-
-begin
-  Result:=Size;
-end;
-
-
-constructor TBytesField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  SetDataType(ftBytes);
-  Size:=16;
-end;
-
-
-
-{ TVarBytesField }
-
-function TVarBytesField.GetDataSize: Word;
-
-begin
-  Result:=Size+2;
-end;
-
-
-constructor TVarBytesField.Create(AOwner: TComponent);
-
-begin
-  INherited Create(AOwner);
-  SetDataType(ftvarbytes);
-  Size:=16;
-end;
-
-{ TBCDField }
-
-class procedure TBCDField.CheckTypeSize(AValue: Longint);
-
-begin
-  If not (AValue in [1..4]) then
-    DatabaseErrorfmt(SInvalidFieldSize,[Avalue]);
-end;
-
-function TBCDField.GetAsCurrency: Currency;
-
-begin
-  if not GetData(@Result) then
-    result := 0;
-end;
-
-function TBCDField.GetAsVariant: Variant;
-
-Var c : system.Currency;
-
-begin
-  If GetData(@c) then
-    Result := c
-  else
-    Result:=Null;
-end;
-
-function TBCDField.GetAsFloat: Double;
-
-begin
-  result := GetAsCurrency;
-end;
-
-
-function TBCDField.GetAsLongint: Longint;
-
-begin
-  result := round(GetAsCurrency);
-end;
-
-
-function TBCDField.GetAsString: string;
-
-var c : system.currency;
-
-begin
-  If GetData(@C) then
-    Result:=CurrToStr(C)
-  else
-    Result:='';
-end;
-
-function TBCDField.GetValue(var AValue: Currency): Boolean;
-
-begin
-  Result := GetData(@AValue);
-end;
-
-function TBCDField.GetDataSize: Word;
-
-begin
-  result := sizeof(system.currency);
-end;
-
-function TBCDField.GetDefaultWidth: Longint;
-
-begin
-  if precision > 0 then result := precision
-    else result := 10;
-end;
-
-procedure TBCDField.GetText(var TheText: string; ADisplayText: Boolean);
-var
-  c : system.currency;
-  fmt: String;
-begin
-  if GetData(@C) then begin
-    if aDisplayText or (FEditFormat='') then
-      fmt := FDisplayFormat
-    else
-      fmt := FEditFormat;
-    if fmt<>'' then
-      TheText := FormatFloat(fmt,C)
-    else if fCurrency then begin
-      if aDisplayText then
-        TheText := FloatToStrF(C, ffCurrency, FPrecision, 2{digits?})
-      else
-        TheText := FloatToStrF(C, ffFixed, FPrecision, 2{digits?});
-    end else
-      TheText := FloatToStrF(C, ffGeneral, FPrecision, 0{digits?});
-  end else
-    TheText := '';
-end;
-
-procedure TBCDField.SetAsCurrency(AValue: Currency);
-
-begin
-  If CheckRange(AValue) then
-    setdata(@AValue)
-  else
-    RangeError(AValue,FMinValue,FMaxvalue);
-end;
-
-procedure TBCDField.SetVarValue(const AValue: Variant);
-begin
-  SetAsCurrency(AValue);
-end;
-
-Function TBCDField.CheckRange(AValue : Currency) : Boolean;
-
-begin
-  If (FMinValue<>0) or (FmaxValue<>0) then
-    Result:=(AValue>=FMinValue) and (AVAlue<=FMaxValue)
-  else
-    Result:=True;
-end;
-
-procedure TBCDField.SetAsFloat(AValue: Double);
-
-begin
-  SetAsCurrency(AValue);
-end;
-
-
-procedure TBCDField.SetAsLongint(AValue: Longint);
-
-begin
-  SetAsCurrency(AValue);
-end;
-
-
-procedure TBCDField.SetAsString(const AValue: string);
-
-begin
-  SetAsCurrency(strtocurr(AValue));
-end;
-
-constructor TBCDField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  FMaxvalue := 0;
-  FMinvalue := 0;
-  SetDataType(ftBCD);
-  FPrecision := 15;
-  Size:=4;
-end;
-
-
-{ TBlobField }
-
-
-procedure TBlobField.AssignTo(Dest: TPersistent);
-
-begin
-  //!! To be implemented
-end;
-
-Function TBlobField.GetBlobStream(Mode : TBlobStreamMode) : TStream;
-
-begin
-  Result:=FDataset.CreateBlobStream(Self,Mode);
-end;
-
-procedure TBlobField.FreeBuffers;
-
-begin
-end;
-
-
-function TBlobField.GetAsString: string;
-var
-  Stream : TStream;
-  Len    : Integer;
-begin
-  Stream := GetBlobStream(bmRead);
-  if Stream <> nil then
-    With Stream do
-      try
-        Len := Size;
-        SetLength(Result, Len);
-        if Len > 0 then
-          ReadBuffer(Result[1], Len);
-      finally
-        Free
-      end
-  else
-    Result := '';
-end;
-
-function TBlobField.GetAsWideString: WideString;
-var
-  Stream : TStream;
-  Len    : Integer;
-begin
-  Stream := GetBlobStream(bmRead);
-  if Stream <> nil then
-    With Stream do
-      try
-        Len := Size;
-        SetLength(Result,Len div 2);
-        if Len > 0 then
-          ReadBuffer(Result[1] ,Len);
-      finally
-        Free
-      end
-  else
-    Result := '';
-end;
-
-function TBlobField.GetAsVariant: Variant;
-
-Var s : string;
-
-begin
-  if not GetIsNull then
-    begin
-    s := GetAsString;
-    result := s;
-    end
-  else result := Null;
-end;
-
-
-function TBlobField.GetBlobSize: Longint;
-var
-  Stream: TStream;
-begin
-  Stream := GetBlobStream(bmread);
-  if Stream <> nil then
-    With Stream do
-      try
-        Result:=Size;
-      finally
-        Free;
-      end
-  else
-    result := 0;
-end;
-
-
-function TBlobField.GetIsNull: Boolean;
-
-begin
-  If Not Modified then
-    result:= inherited GetIsnull
-  else
-    With GetBlobStream(bmread) do
-      try
-        Result:=(Size=0);
-      Finally
-        Free;
-      end;
-end;
-
-
-procedure TBlobField.GetText(var TheText: string; ADisplayText: Boolean);
-
-begin
-  TheText:=inherited GetAsString;
-end;
-
-
-procedure TBlobField.SetAsString(const AValue: string);
-var
-  Len : Integer;
-begin
-  With GetBlobStream(bmwrite) do
-    try
-      Len := Length(Avalue);
-      if Len > 0 then
-        WriteBuffer(aValue[1], Len);
-    finally
-      Free;
-    end;
-end;
-
-
-procedure TBlobField.SetAsWideString(const AValue: WideString);
-var
-  Len : Integer;
-begin
-  With GetBlobStream(bmwrite) do
-    try
-      Len := Length(Avalue) * 2;
-      if Len > 0 then
-        WriteBuffer(aValue[1], Len);
-    finally
-      Free;
-    end;
-end;
-
-
-procedure TBlobField.SetText(const AValue: string);
-
-begin
-  SetAsString(AValue);
-end;
-
-procedure TBlobField.SetVarValue(const AValue: Variant);
-begin
-  SetAsString(AValue);
-end;
-
-
-constructor TBlobField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOWner);
-  SetDataType(ftBlob);
-end;
-
-
-procedure TBlobField.Assign(Source: TPersistent);
-
-begin
-  //!! To be implemented
-end;
-
-
-procedure TBlobField.Clear;
-
-begin
-  GetBlobStream(bmWrite).free;
-end;
-
-
-class function TBlobField.IsBlob: Boolean;
-
-begin
-  Result:=True;
-end;
-
-
-procedure TBlobField.LoadFromFile(const FileName: string);
-
-Var S : TFileStream;
-
-begin
-  S:=TFileStream.Create(FileName,fmOpenRead);
-  try
-    LoadFromStream(S);
-  finally
-    S.Free;
-  end;
-end;
-
-
-procedure TBlobField.LoadFromStream(Stream: TStream);
-
-begin
-  With GetBlobStream(bmWrite) do
-    Try
-      CopyFrom(Stream,0);
-    finally
-      Free;
-    end;
-end;
-
-
-procedure TBlobField.SaveToFile(const FileName: string);
-
-Var S : TFileStream;
-
-begin
-  S:=TFileStream.Create(FileName,fmCreate);
-  try
-    SaveToStream(S);
-  finally
-    S.Free;
-  end;
-end;
-
-
-procedure TBlobField.SaveToStream(Stream: TStream);
-
-Var S : TStream;
-
-begin
-  S:=GetBlobStream(bmRead);
-  Try
-    Stream.CopyFrom(S,0);
-  finally
-    S.Free;
-  end;
-end;
-
-procedure TBlobField.SetFieldType(AValue: TFieldType);
-
-begin
-  If AValue in [Low(TBlobType)..High(TBlobType)] then
-    SetDatatype(Avalue);
-end;
-
-{ TMemoField }
-
-constructor TMemoField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  SetDataType(ftMemo);
-end;
-
-function TMemoField.GetAsWideString: WideString;
-begin
-  Result := GetAsString;
-end;
-
-procedure TMemoField.SetAsWideString(const aValue: WideString);
-begin
-  SetAsString(aValue);
-end;
-
-{ TWideMemoField }
-
-constructor TWideMemoField.Create(AOwner: TComponent);
-begin
-  inherited Create(AOwner);
-  SetDataType(ftWideMemo);
-end;
-
-function TWideMemoField.GetAsString: string;
-begin
-  Result := GetAsWideString;
-end;
-
-procedure TWideMemoField.SetAsString(const aValue: string);
-begin
-  SetAsWideString(aValue);
-end;
-
-function TWideMemoField.GetAsVariant: Variant;
-
-Var s : string;
-
-begin
-  if not GetIsNull then
-    begin
-    s := GetAsWideString;
-    result := s;
-    end
-  else result := Null;
-end;
-
-procedure TWideMemoField.SetVarValue(const AValue: Variant);
-begin
-  SetAsWideString(AValue);
-end;
-
-{ TGraphicField }
-
-constructor TGraphicField.Create(AOwner: TComponent);
-
-begin
-  Inherited Create(AOwner);
-  SetDataType(ftGraphic);
-end;
-
-{ TGuidField }
-
-constructor TGuidField.Create(AOwner: TComponent);
-begin
-  Size := 38;
-  inherited Create(AOwner);
-  SetDataType(ftGuid);
-end;
-
-class procedure TGuidField.CheckTypeSize(AValue: LongInt);
-begin
-  if aValue <> 38 then
-    DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
-end;
-
-function TGuidField.GetAsGuid: TGUID;
-const
-  nullguid: TGUID = '{00000000-0000-0000-0000-000000000000}';
-var
-  S: string;
-begin
-  S := GetAsString;
-  if S = '' then
-    Result := nullguid
-  else
-    Result := StringToGuid(S);
-end;
-
-function TGuidField.GetDefaultWidth: LongInt;
-begin
-  Result := 38;
-end;
-
-procedure TGuidField.SetAsGuid(const aValue: TGUID);
-begin
-  SetAsString(GuidToString(aValue));
-end;
-
-function TVariantField.GetDefaultWidth: Integer;
-begin
-  Result := 15;
-end;
-
-{ TVariantField }
-
-constructor TVariantField.Create(AOwner: TComponent);
-begin
-  inherited Create(AOwner);
-  SetDataType(ftVariant);
-end;
-
-class procedure TVariantField.CheckTypeSize(aValue: Integer);
-begin
-  { empty }
-end;
-
-function TVariantField.GetAsBoolean: Boolean;
-begin
-  Result := GetAsVariant;
-end;
-
-function TVariantField.GetAsDateTime: TDateTime;
-begin
-  Result := GetAsVariant;
-end;
-
-function TVariantField.GetAsFloat: Double;
-begin
-  Result := GetAsVariant;
-end;
-
-function TVariantField.GetAsInteger: Longint;
-begin
-  Result := GetAsVariant;
-end;
-
-function TVariantField.GetAsString: string;
-begin
-  Result := VarToStr(GetAsVariant);
-end;
-
-function TVariantField.GetAsWideString: WideString;
-begin
-  Result := VarToWideStr(GetAsVariant);
-end;
-
-function TVariantField.GetAsVariant: Variant;
-begin
-  if not GetData(@Result) then
-    Result := Null;
-end;
-
-procedure TVariantField.SetAsBoolean(aValue: Boolean);
-begin
-  SetVarValue(aValue);
-end;
-
-procedure TVariantField.SetAsDateTime(aValue: TDateTime);
-begin
-  SetVarValue(aValue);
-end;
-
-procedure TVariantField.SetAsFloat(aValue: Double);
-begin
-  SetVarValue(aValue);
-end;
-
-procedure TVariantField.SetAsInteger(aValue: Longint);
-begin
-  SetVarValue(aValue);
-end;
-
-procedure TVariantField.SetAsString(const aValue: string);
-begin
-  SetVarValue(aValue);
-end;
-
-procedure TVariantField.SetAsWideString(const aValue: WideString);
-begin
-  SetVarValue(aValue);
-end;
-
-procedure TVariantField.SetVarValue(const aValue: Variant);
-begin
-  SetData(@aValue);
-end;
-
-
-{ TFields }
-
-Constructor TFields.Create(ADataset : TDataset);
-
-begin
-  FDataSet:=ADataset;
-  FFieldList:=TList.Create;
-  FValidFieldKinds:=[fkData..fkInternalcalc];
-end;
-
-Destructor TFields.Destroy;
-
-begin
-  if FFieldList <> nil then Clear;
-  FFieldList.Free;
-  inherited Destroy;
-end;
-
-Procedure Tfields.Changed;
-
-begin
-  if (FDataSet <> nil) and not (csDestroying in FDataSet.ComponentState) and FDataset.Active then
-    FDataSet.DataEvent(deFieldListChange, 0);
-  If Assigned(FOnChange) then
-    FOnChange(Self);
-end;
-
-Procedure TFields.CheckfieldKind(Fieldkind : TFieldKind; Field : TField);
-
-begin
-  If Not (FieldKind in ValidFieldKinds) Then
-    DatabaseErrorFmt(SInvalidFieldKind,[Field.FieldName]);
-end;
-
-Function Tfields.GetCount : Longint;
-
-begin
-  Result:=FFieldList.Count;
-end;
-
-
-Function TFields.GetField (Index : longint) : TField;
-
-begin
-  Result:=Tfield(FFieldList[Index]);
-end;
-
-procedure Tfields.SetField(Index: Integer; Value: TField);
-begin
-  Fields[Index].Assign(Value);
-end;
-
-Procedure TFields.SetFieldIndex (Field : TField;Value : Integer);
-
-Var Old : Longint;
-
-begin
-  Old := FFieldList.indexOf(Field);
-  If Old=-1 then
-    Exit;
-  // Check value
-  If Value<0 Then Value:=0;
-  If Value>=Count then Value:=Count-1;
-  If Value<>Old then
-    begin
-    FFieldList.Delete(Old);
-    FFieldList.Insert(Value,Field);
-    Field.PropertyChanged(True);
-    Changed;
-    end;
-end;
-
-Procedure TFields.Add(Field : TField);
-
-begin
-  CheckFieldName(Field.FieldName);
-  FFieldList.Add(Field);
-  Field.FFields:=Self;
-  Changed;
-end;
-
-Procedure TFields.CheckFieldName (Const Value : String);
-
-begin
-  If FindField(Value)<>Nil then
-    DataBaseErrorFmt(SDuplicateFieldName,[Value],FDataset);
-end;
-
-Procedure TFields.CheckFieldNames (Const Value : String);
-
-
-Var I : longint;
-    S,T : String;
-begin
-  T:=Value;
-  Repeat
-    I:=Pos(';',T);
-    If I=0 Then I:=Length(T)+1;
-    S:=Copy(T,1,I-1);
-    Delete(T,1,I);
-    // Will raise an error if no such field...
-    FieldByName(S);
-  Until (T='');
-end;
-
-Procedure TFields.Clear;
-
-begin
-  with FFieldList do
-    while Count > 0 do begin
-      TField(Last).FDataSet := Nil;
-      TField(Last).Free;
-      FFieldList.Delete(Count - 1);
-    end;
-  Changed;
-end;
-
-Function TFields.FindField (Const Value : String) : TField;
-
-Var S : String;
-    I : longint;
-
-begin
-  Result:=Nil;
-  S:=UpperCase(Value);
-  For I:=0 To FFieldList.Count-1 do
-    If S=UpperCase(TField(FFieldList[i]).FieldName) Then
-      Begin
-      {$ifdef dsdebug}
-      Writeln ('Found field ',Value);
-      {$endif}
-      Result:=TField(FFieldList[I]);
-      Exit;
-      end;
-end;
-
-Function TFields.FieldByName (Const Value : String) : TField;
-
-begin
-  Result:=FindField(Value);
-  If result=Nil then
-    DatabaseErrorFmt(SFieldNotFound,[Value],FDataset);
-end;
-
-Function TFields.FieldByNumber(FieldNo : Integer) : TField;
-
-Var i : Longint;
-
-begin
-  Result:=Nil;
-  For I:=0 to FFieldList.Count-1 do
-    If FieldNo=TField(FFieldList[I]).FieldNo then
-      begin
-      Result:=TField(FFieldList[i]);
-      Exit;
-      end;
-end;
-
-Procedure TFields.GetFieldNames (Values : TStrings);
-
-Var i : longint;
-
-begin
-  Values.Clear;
-  For I:=0 to FFieldList.Count-1 do
-    Values.Add(Tfield(FFieldList[I]).FieldName);
-end;
-
-Function TFields.IndexOf(Field : TField) : Longint;
-
-begin
-  Result:=FFieldList.IndexOf(Field);
-end;
-
-procedure TFields.Remove(Value : TField);
-
-begin
-  FFieldList.Remove(Value);
-  Value.FFields := nil;
-  Changed;
-end;
-

Some files were not shown because too many files changed in this diff