Browse Source

+ Fixes to get dbf to work

michael 25 years ago
parent
commit
10f2c17f03
3 changed files with 91 additions and 14 deletions
  1. 12 2
      fcl/db/dataset.inc
  2. 58 3
      fcl/db/db.pp
  3. 21 9
      fcl/db/fields.inc

+ 12 - 2
fcl/db/dataset.inc

@@ -72,9 +72,10 @@ begin
      Here some magic will be needed later; for now just simply set
      Here some magic will be needed later; for now just simply set
      Just set fieldno from listindex...
      Just set fieldno from listindex...
      Later we should take it from the fielddefs.
      Later we should take it from the fielddefs.
-  }
+     // ATM Set by CreateField ...
   For I:=0 to FFieldList.Count-1 do
   For I:=0 to FFieldList.Count-1 do
     FFieldList[i].FFieldNo:=I;
     FFieldList[i].FFieldNo:=I;
+  }  
 end;
 end;
 
 
 Function TDataset.BookmarkAvailable: Boolean;
 Function TDataset.BookmarkAvailable: Boolean;
@@ -141,11 +142,17 @@ Var I : longint;
 begin
 begin
 {$ifdef DSDebug}
 {$ifdef DSDebug}
   Writeln ('Creating fields');
   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}
 {$endif}
   For I:=0 to fielddefs.Count-1 do
   For I:=0 to fielddefs.Count-1 do
     With Fielddefs.Items[I] do
     With Fielddefs.Items[I] do
       If DataType<>ftUnknown then
       If DataType<>ftUnknown then
+        begin
+        Writeln('About to create field',FieldDefs.Items[i].Name);
         CreateField(self);
         CreateField(self);
+        end;
 end;
 end;
 
 
 Procedure TDataset.DataEvent(Event: TDataEvent; Info: Longint);
 Procedure TDataset.DataEvent(Event: TDataEvent; Info: Longint);
@@ -1586,7 +1593,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.1.2.4  2001-01-11 23:46:28  sg
+  Revision 1.1.2.5  2001-01-16 22:59:59  michael
+  + Fixes to get dbf to work
+
+  Revision 1.1.2.4  2001/01/11 23:46:28  sg
   * Some bugfixes... :)
   * Some bugfixes... :)
 
 
   Revision 1.1.2.3  2000/12/23 23:23:49  sg
   Revision 1.1.2.3  2000/12/23 23:23:49  sg

+ 58 - 3
fcl/db/db.pp

@@ -34,6 +34,8 @@ const
   YesNoChars : Array[Boolean] of char = ('Y','N');
   YesNoChars : Array[Boolean] of char = ('Y','N');
 
 
 type
 type
+{LargeInt}
+  LargeInt = Int64;
 
 
 { Auxiliary type }
 { Auxiliary type }
   TStringFieldBuffer = Array[0..dsMaxStringSize] of Char;
   TStringFieldBuffer = Array[0..dsMaxStringSize] of Char;
@@ -69,10 +71,20 @@ type
 
 
   TFieldClass = class of TField;
   TFieldClass = class of TField;
 
 
+{
   TFieldType = (ftUnknown, ftString, ftSmallint, ftInteger, ftWord,
   TFieldType = (ftUnknown, ftString, ftSmallint, ftInteger, ftWord,
     ftBoolean, ftFloat, ftDate, ftTime, ftDateTime,
     ftBoolean, ftFloat, ftDate, ftTime, ftDateTime,
     ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftMemo, ftGraphic,
     ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftMemo, ftGraphic,
     ftFmtMemo, ftParadoxOle, ftDBaseOle, ftTypedBinary, ftCursor);
     ftFmtMemo, ftParadoxOle, ftDBaseOle, ftTypedBinary, ftCursor);
+}    
+    
+  TFieldType = (ftUnknown, ftString, ftSmallint, ftInteger, ftWord, 
+    ftBoolean, ftFloat, ftCurrency, ftBCD, ftDate,  ftTime, ftDateTime, 
+    ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftMemo, ftGraphic, ftFmtMemo, 
+    ftParadoxOle, ftDBaseOle, ftTypedBinary, ftCursor, ftFixedChar, 
+    ftWideString, ftLargeint, ftADT, ftArray, ftReference, 
+    ftDataSet, ftOraBlob, ftOraClob, ftVariant, ftInterface, 
+    ftIDispatch, ftGuid, ftTimeStamp, ftFMTBcd);
 
 
   TFieldDef = class(TComponent)
   TFieldDef = class(TComponent)
   Private
   Private
@@ -1189,7 +1201,47 @@ type
 
 
 Const
 Const
   Fieldtypenames : Array [TFieldType] of String[15] =
   Fieldtypenames : Array [TFieldType] of String[15] =
-    ( 'Unknown',
+    (
+      'Unknown', 
+      'String', 
+      'Smallint', 
+      'Integer', 
+      'Word', 
+      'Boolean', 
+      'Float', 
+      'Currency', 
+      'BCD', 
+      'Date',  
+      'Time', 
+      'DateTime', 
+      'Bytes', 
+      'VarBytes', 
+      'AutoInc', 
+      'Blob', 
+      'Memo', 
+      'Graphic', 
+      'FmtMemo', 
+      'ParadoxOle', 
+      'DBaseOle', 
+      'TypedBinary', 
+      'Cursor', 
+      'FixedChar', 
+      'WideString', 
+      'Largeint', 
+      'ADT', 
+      'Array', 
+      'Reference', 
+      'DataSet', 
+      'OraBlob', 
+      'OraClob', 
+      'Variant', 
+      'Interface', 
+      'IDispatch', 
+      'Guid', 
+      'TimeStamp', 
+      'FMTBcd'
+    );
+    { 'Unknown',
       'String',
       'String',
       'Smallint',
       'Smallint',
       'Integer',
       'Integer',
@@ -1210,7 +1262,7 @@ Const
       'DBaseOle',
       'DBaseOle',
       'TypedBinary',
       'TypedBinary',
       'Cursor'
       'Cursor'
-    );
+    );}
 
 
    dsEditModes = [dsEdit, dsInsert];
    dsEditModes = [dsEdit, dsInsert];
 { Auxiliary functions }
 { Auxiliary functions }
@@ -1405,7 +1457,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.1.2.4  2001-01-11 23:46:28  sg
+  Revision 1.1.2.5  2001-01-16 23:00:25  michael
+  + Fixes to get dbf to work
+
+  Revision 1.1.2.4  2001/01/11 23:46:28  sg
   * Some bugfixes... :)
   * Some bugfixes... :)
 
 
   Revision 1.1.2.3  2000/12/23 23:26:45  sg
   Revision 1.1.2.3  2000/12/23 23:26:45  sg

+ 21 - 9
fcl/db/fields.inc

@@ -36,6 +36,9 @@ Constructor TFieldDef.Create(AOwner: TFieldDefs; const AName: string;
 
 
 begin
 begin
   Inherited Create(AOwner);
   Inherited Create(AOwner);
+{$ifdef dsdebug }
+  Writeln('TFieldDef.Create : ',Aname,'(',AFieldNo,')');
+{$endif}  
   FName:=Aname;
   FName:=Aname;
   FDatatype:=ADatatype;
   FDatatype:=ADatatype;
   FSize:=ASize;
   FSize:=ASize;
@@ -48,6 +51,7 @@ begin
     end
     end
   else If FDataType in [ftWord,ftsmallint,ftinteger] Then
   else If FDataType in [ftWord,ftsmallint,ftinteger] Then
     If Not (FSize in [1,2,4]) then FSize:=4;
     If Not (FSize in [1,2,4]) then FSize:=4;
+  
   FFieldNo:=AFieldNo;
   FFieldNo:=AFieldNo;
   AOwner.FItems.Add(Self);
   AOwner.FItems.Add(Self);
 end;
 end;
@@ -65,7 +69,7 @@ Function TFieldDef.CreateField(AOwner: TComponent): TField;
 Var TheField : TFieldClass;
 Var TheField : TFieldClass;
 
 
 begin
 begin
-  Writeln ('Creating field');
+  Writeln ('Creating field'+FNAME);
   TheField:=GetFieldClass;
   TheField:=GetFieldClass;
   if TheField=Nil then
   if TheField=Nil then
     DatabaseErrorFmt(SUnknownFieldType,[FName]);
     DatabaseErrorFmt(SUnknownFieldType,[FName]);
@@ -74,8 +78,14 @@ begin
     Result.Size:=FSize;
     Result.Size:=FSize;
     Result.Required:=FRequired;
     Result.Required:=FRequired;
     Result.FieldName:=FName;
     Result.FieldName:=FName;
+    Result.FFieldNo:=Self.FieldNo;
     Result.SetFieldType(DataType);
     Result.SetFieldType(DataType);
-    Writeln ('Trying to set dataset');
+{$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(Owner).FDataset;
     Result.Dataset:=TFieldDefs(Owner).FDataset;
     If Result is TFloatField then
     If Result is TFloatField then
       TFloatField(Result).Precision:=FPrecision;
       TFloatField(Result).Precision:=FPrecision;
@@ -83,6 +93,7 @@ begin
     Result.Free;
     Result.Free;
     Raise;
     Raise;
   end;
   end;
+  
 end;
 end;
 
 
 Function TFieldDef.GetFieldClass : TFieldClass;
 Function TFieldDef.GetFieldClass : TFieldClass;
@@ -112,12 +123,11 @@ procedure TFieldDefs.Add(const AName: string; ADataType: TFieldType; ASize: Word
   ARequired: Boolean);
   ARequired: Boolean);
 
 
 begin
 begin
-  Writeln ('Adding fielddef');
-  If Length(Name)=0 Then 
+  If Length(AName)=0 Then 
     DatabaseError(SNeedFieldName);
     DatabaseError(SNeedFieldName);
   // the fielddef will register itself here as a owned component.
   // the fielddef will register itself here as a owned component.
   // fieldno is 1 based !
   // fieldno is 1 based !
-  FItems.Add(TFieldDef.Create(Self,AName,ADataType,ASize,Arequired,FItems.Count+1));
+  TFieldDef.Create(Self,AName,ADataType,ASize,Arequired,FItems.Count+1);
 end;
 end;
 
 
 function TFieldDefs.GetCount: Longint;
 function TFieldDefs.GetCount: Longint;
@@ -453,7 +463,9 @@ end;
 Procedure TField.SetDataset (Value : TDataset);
 Procedure TField.SetDataset (Value : TDataset);
 
 
 begin
 begin
+{$ifdef dsdebug}
   Writeln ('Setting dataset');
   Writeln ('Setting dataset');
+{$endif}  
   If Value=FDataset then exit;
   If Value=FDataset then exit;
   If Assigned(FDataset) Then FDataset.CheckInactive;
   If Assigned(FDataset) Then FDataset.CheckInactive;
   If Assigned(Value) then
   If Assigned(Value) then
@@ -465,10 +477,7 @@ begin
   If Assigned(FDataset) then
   If Assigned(FDataset) then
     FDataset.FFieldList.Remove(Self);
     FDataset.FFieldList.Remove(Self);
   If Assigned(Value) then 
   If Assigned(Value) then 
-    begin
-    Writeln('Adding field to list..');
     Value.FFieldList.Add(Self);
     Value.FFieldList.Add(Self);
-    end;
   FDataset:=Value;    
   FDataset:=Value;    
 end;
 end;
 
 
@@ -1764,7 +1773,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.1.2.2  2000-12-23 23:27:25  sg
+  Revision 1.1.2.3  2001-01-16 23:00:00  michael
+  + Fixes to get dbf to work
+
+  Revision 1.1.2.2  2000/12/23 23:27:25  sg
   * Added TField.DisplayText, and accordingly changed all arguments called
   * Added TField.DisplayText, and accordingly changed all arguments called
     DisplayText to ADisplayText
     DisplayText to ADisplayText