Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-09

Sdf / Fixed maximum line length flexibilization

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

Sdf / Fixed datasets have a constant for the maximum line size, but this one is too small for me, so I changed the constant into a field in the class so it can be customized. I tested and it works for me.

I just thougth someone may have a better idea, so I am showing the patch here for review and will apply in some days if noone has a better idea.

Index: sdfdata.pp
=================================================================== --- sdfdata.pp (revision 11718)
+++ sdfdata.pp (working copy)
@@ -125,9 +125,6 @@
uses

   DB, Classes, SysUtils;
-const
-  MAXSTRLEN = 250;
-
 type
 //-----------------------------------------------------------------------------
 // TRecInfo
@@ -199,6 +196,7 @@
     function BufToStore(Buffer: PChar): String; virtual;
     function StoreToBuf(Source: String): String; virtual;
   public
+    MAXSTRLEN: Integer;
     constructor Create(AOwner: TComponent); override;
     destructor  Destroy; override;
     function  GetFieldData(Field: TField; Buffer: Pointer): Boolean; override;
@@ -274,6 +272,7 @@
 //-----------------------------------------------------------------------------
 constructor TFixedFormatDataSet.Create(AOwner : TComponent);
 begin
+ MAXSTRLEN := 250;
  FFileMustExist  := TRUE;
  FLoadfromStream := False;
  FRecordSize   := 0;

Reply by email

Micha Nelissen
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
function StoreToBuf(Source: String): String; virtual; public + MAXSTRLEN: Integer;

If you don't object, this is a bit ugly to my taste. Why not 'FMaxStrLen', and have a property MaxStrLen: read FMaxStrLen ? Looks better to me.

Micha

Reply by email

Inoussa OUEDRAOGO
to Micha Nelissen

Hi

Show quoted text 8 lines
Felipe Monteiro de Carvalho wrote: > > function StoreToBuf(Source: String): String; virtual; > public > + MAXSTRLEN: Integer; If you don't object, this is a bit ugly to my taste. Why not 'FMaxStrLen', and have a property MaxStrLen: read FMaxStrLen ? Looks better to me.

I second the property declaration with a little modification to make it more readable :

  property MaxStringLength read FMaxStringLength write
FMaxStringLength default 250;
Inoussa O.

Reply by email

Felipe Monteiro de Carvalho
to Inoussa OUEDRAOGO
Inoussa OUEDRAOGO wrote
property MaxStringLength read FMaxStringLength write FMaxStringLength default 250;

I went for this, but named it MaxRecordLength.

Always good to hear other oppinions =) Commited to trunk.

I don't know if there are plans for a 2.2.4, but this would be a nice addition to it.

Felipe Monteiro de Carvalho

Reply by email

Inoussa OUEDRAOGO
to Felipe Monteiro de Carvalho

2008/9/7 Felipe Monteiro de Carvalho :

Show quoted text 5 lines
On 9/7/08, Inoussa OUEDRAOGO wrote: > property MaxStringLength read FMaxStringLength write > FMaxStringLength default 250; I went for this, but named it MaxRecordLength.

even better.

Inoussa O.

Reply by email