Переглянути джерело

+ Fixes to get dbf to work

michael 25 роки тому
батько
коміт
10f2c17f03
3 змінених файлів з 91 додано та 14 видалено
  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
      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;
+  }  
 end;
 
 Function TDataset.BookmarkAvailable: Boolean;
@@ -141,11 +142,17 @@ 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
+        Writeln('About to create field',FieldDefs.Items[i].Name);
         CreateField(self);
+        end;
 end;
 
 Procedure TDataset.DataEvent(Event: TDataEvent; Info: Longint);
@@ -1586,7 +1593,10 @@ end;
 
 {
   $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... :)
 
   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');
 
 type
+{LargeInt}
+  LargeInt = Int64;
 
 { Auxiliary type }
   TStringFieldBuffer = Array[0..dsMaxStringSize] of Char;
@@ -69,10 +71,20 @@ type
 
   TFieldClass = class of TField;
 
+{
   TFieldType = (ftUnknown, ftString, ftSmallint, ftInteger, ftWord,
     ftBoolean, ftFloat, ftDate, ftTime, ftDateTime,
     ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftMemo, ftGraphic,
     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)
   Private
@@ -1189,7 +1201,47 @@ type
 
 Const
   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',
       'Smallint',
       'Integer',
@@ -1210,7 +1262,7 @@ Const
       'DBaseOle',
       'TypedBinary',
       'Cursor'
-    );
+    );}
 
    dsEditModes = [dsEdit, dsInsert];
 { Auxiliary functions }
@@ -1405,7 +1457,10 @@ end.
 
 {
   $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... :)
 
   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
   Inherited Create(AOwner);
+{$ifdef dsdebug }
+  Writeln('TFieldDef.Create : ',Aname,'(',AFieldNo,')');
+{$endif}  
   FName:=Aname;
   FDatatype:=ADatatype;
   FSize:=ASize;
@@ -48,6 +51,7 @@ begin
     end
   else If FDataType in [ftWord,ftsmallint,ftinteger] Then
     If Not (FSize in [1,2,4]) then FSize:=4;
+  
   FFieldNo:=AFieldNo;
   AOwner.FItems.Add(Self);
 end;
@@ -65,7 +69,7 @@ Function TFieldDef.CreateField(AOwner: TComponent): TField;
 Var TheField : TFieldClass;
 
 begin
-  Writeln ('Creating field');
+  Writeln ('Creating field'+FNAME);
   TheField:=GetFieldClass;
   if TheField=Nil then
     DatabaseErrorFmt(SUnknownFieldType,[FName]);
@@ -74,8 +78,14 @@ begin
     Result.Size:=FSize;
     Result.Required:=FRequired;
     Result.FieldName:=FName;
+    Result.FFieldNo:=Self.FieldNo;
     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;
     If Result is TFloatField then
       TFloatField(Result).Precision:=FPrecision;
@@ -83,6 +93,7 @@ begin
     Result.Free;
     Raise;
   end;
+  
 end;
 
 Function TFieldDef.GetFieldClass : TFieldClass;
@@ -112,12 +123,11 @@ procedure TFieldDefs.Add(const AName: string; ADataType: TFieldType; ASize: Word
   ARequired: Boolean);
 
 begin
-  Writeln ('Adding fielddef');
-  If Length(Name)=0 Then 
+  If Length(AName)=0 Then 
     DatabaseError(SNeedFieldName);
   // the fielddef will register itself here as a owned component.
   // 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;
 
 function TFieldDefs.GetCount: Longint;
@@ -453,7 +463,9 @@ end;
 Procedure TField.SetDataset (Value : TDataset);
 
 begin
+{$ifdef dsdebug}
   Writeln ('Setting dataset');
+{$endif}  
   If Value=FDataset then exit;
   If Assigned(FDataset) Then FDataset.CheckInactive;
   If Assigned(Value) then
@@ -465,10 +477,7 @@ begin
   If Assigned(FDataset) then
     FDataset.FFieldList.Remove(Self);
   If Assigned(Value) then 
-    begin
-    Writeln('Adding field to list..');
     Value.FFieldList.Add(Self);
-    end;
   FDataset:=Value;    
 end;
 
@@ -1764,7 +1773,10 @@ end;
 
 {
   $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
     DisplayText to ADisplayText