Browse Source

+ Added append() insert() tested append. Datetime as string works now

michael 26 years ago
parent
commit
35291cd4b2
6 changed files with 228 additions and 133 deletions
  1. 5 4
      fcl/db/Makefile
  2. 174 121
      fcl/db/dataset.inc
  3. 7 2
      fcl/db/db.pp
  4. 6 2
      fcl/db/dbs.inc
  5. 14 2
      fcl/db/ddg_ds.pp
  6. 22 2
      fcl/db/fields.inc

+ 5 - 4
fcl/db/Makefile

@@ -124,8 +124,8 @@ endif
 
 # Targets
 
-UNITOBJECTS=db ddg_ds ddg_rec mysqldb
-EXEOBJECTS=testds createds mtest
+UNITOBJECTS=db ddg_ds ddg_rec
+EXEOBJECTS=testds createds tested
 
 # Clean
 
@@ -134,8 +134,7 @@ EXEOBJECTS=testds createds mtest
 
 
 # Defaults
-
-DEFAULTUNITS=1
+# DEFAULTUNITS=1
 override NEEDOPT=-S2
 
 # Directories
@@ -954,6 +953,8 @@ ddg_ds$(PPUEXT): db$(PPUEXT) ddg_rec$(PPUEXT) ddg_ds$(PASEXT)
 
 testds$(EXEEXT): ddg_ds$(PPUEXT) testds$(PASEXT)
 
+tested$(EXEEXT): ddg_ds$(PPUEXT) tested$(PASEXT)
+
 createds$(EXEEXT): createds$(PASEXT) ddg_rec$(PPUEXT)
 
 mysqldb$(PPUEXT): db$(PPUEXT) mysqldb$(PASEXT)

File diff suppressed because it is too large
+ 174 - 121
fcl/db/dataset.inc


+ 7 - 2
fcl/db/db.pp

@@ -191,6 +191,7 @@ type
     function GetCanModify: Boolean; virtual;
     function GetDataSize: Word; virtual;
     function GetDefaultWidth: Longint; virtual;
+    function GetDisplayName : String; 
     function GetIsNull: Boolean; virtual;
     function GetParentComponent: TComponent; override;
     procedure GetText(var AText: string; ADisplayText: Boolean); virtual;
@@ -242,7 +243,8 @@ type
     property CustomConstraint: string read FCustomConstraint write FCustomConstraint;
     property ConstraintErrorMessage: string read FConstraintErrorMessage write FConstraintErrorMessage;
     property DefaultExpression: string read FDefaultExpression write FDefaultExpression;
-    property DisplayLabel: string read FDisplayLabel write FDisplayLabel;
+    property DisplayLabel : string read FDisplayLabel write FDisplayLabel;
+    property DisplayName : String Read GetDisplayName; 
     property DisplayWidth: Longint read FDisplayWidth write FDisplayWidth;
     property FieldKind: TFieldKind read FFieldKind write FFieldKind;
     property FieldName: string read FFieldName write FFieldName;
@@ -1258,7 +1260,10 @@ end.
 
 {
   $Log$
-  Revision 1.4  1999-11-11 17:31:09  michael
+  Revision 1.5  1999-11-12 22:53:32  michael
+  + Added append() insert() tested append. Datetime as string works now
+
+  Revision 1.4  1999/11/11 17:31:09  michael
   + Added Checks for all simple field types.
   + Initial implementation of Insert/Append
 

+ 6 - 2
fcl/db/dbs.inc

@@ -41,10 +41,14 @@ Const
   SConnected = 'Operation cannot be performed on an connected database';
   SNoSuchRecord = 'Could not find the requested record.';  
   SDatasetReadOnly = 'Dataset is read-only.';
-
+  SNeedField = 'Field %s is required, but not supplied.';
+  
 {
   $Log$
-  Revision 1.3  1999-11-11 17:31:09  michael
+  Revision 1.4  1999-11-12 22:53:32  michael
+  + Added append() insert() tested append. Datetime as string works now
+
+  Revision 1.3  1999/11/11 17:31:09  michael
   + Added Checks for all simple field types.
   + Initial implementation of Insert/Append
 

+ 14 - 2
fcl/db/ddg_ds.pp

@@ -268,7 +268,13 @@ begin
   case Field.Index of
     0: Move(Buffer^, ActiveBuffer^, Field.Size);
     1: Move(Buffer^, PDDGData(ActiveBuffer)^.Height, Field.DataSize);
-    2: Move(Buffer^, PDDGData(ActiveBuffer)^.ShoeSize, Field.DataSize);
+    2: Move(Buffer^, PDDGData(ActiveBuffer)^.LongField, Field.DataSize);
+    3: Move(Buffer^, PDDGData(ActiveBuffer)^.ShoeSize, Field.DataSize);
+    4: Move(Buffer^, PDDGData(ActiveBuffer)^.WordField, Field.DataSize);
+    5: Move(Buffer^, PDDGData(ActiveBuffer)^.DateTimeField, Field.DataSize);
+    6: Move(Buffer^, PDDGData(ActiveBuffer)^.TimeField, Field.DataSize);
+    7: Move(Buffer^, PDDGData(ActiveBuffer)^.DateField, Field.DataSize);
+    8: Move(Buffer^, PDDGData(ActiveBuffer)^.Even, Field.DataSize);
   end;
   DataEvent(deFieldChange, Longint(Field));
 end;
@@ -399,7 +405,7 @@ begin
       DatabaseError('Could not open table');
   end;
   // open data file
-  FileMode := fmOpenRead;
+  FileMode := fmOpenReadWrite;
   Writeln ('OPening data file');
   AssignFile(FDataFile, FTableName);
   Reset(FDataFile);  
@@ -442,6 +448,9 @@ begin
     else RecPos := FileSize(FDataFile);
   end;
   Seek(FDataFile, RecPos);
+ {$ifdef dsdebug}
+  Writeln ('Writing record to disk.');
+ {$endif}
   BlockWrite(FDataFile, PDDGData(ActiveBuffer)^, 1);
   if State <> dsEdit then
   begin
@@ -449,6 +458,9 @@ begin
     else InsPos := FRecordPos;
     FIndexList.Insert(InsPos, Pointer(RecPos));
   end;
+ {$ifdef dsdebug}
+  Writeln ('Writing index to disk.');
+ {$endif}
   FIndexList.SaveToFile(FIdxName);
 end;
 

+ 22 - 2
fcl/db/fields.inc

@@ -341,6 +341,15 @@ begin
   Result:=10;
 end;
 
+function TField.GetDisplayName  : String;
+
+begin
+  If FDisplayLabel<>'' then
+    result:=FDisplayLabel
+  else
+    Result:=FFieldName;
+end;
+
 function TField.getIndex : longint;
 
 begin
@@ -968,7 +977,10 @@ end;
 Function TFloatField.CheckRange(AValue : Extended) : Boolean;
 
 begin
-  Result:=(AValue>=FMinValue) and (AVAlue<=FMAxValue);
+  If (FMinValue<>0) or (FmaxValue<>0) then
+    Result:=(AValue>=FMinValue) and (AVAlue<=FMAxValue)
+  else
+    Result:=True;
 end;
 
 
@@ -1102,6 +1114,8 @@ begin
       Case DataType of
        ftTime : F:=ShortTimeFormat;
        ftDate : F:=ShortDateFormat;
+      else
+       F:='c'
       end;
     TheText:=FormatDateTime(F,R);
     end;
@@ -1675,6 +1689,9 @@ begin
   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;
@@ -1735,7 +1752,10 @@ end;
 
 {
   $Log$
-  Revision 1.3  1999-11-11 17:31:09  michael
+  Revision 1.4  1999-11-12 22:53:32  michael
+  + Added append() insert() tested append. Datetime as string works now
+
+  Revision 1.3  1999/11/11 17:31:09  michael
   + Added Checks for all simple field types.
   + Initial implementation of Insert/Append
 

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