[lazarus] mwEdit Problems

Cliff Baeseman vbman at pcpros.net
Thu Oct 21 01:28:05 EDT 1999


Curtis

see my comment and rewrite below this may fix it then again it may not

Cliff

-----Original Message-----
From: Curtis White <osiriz at teleport.com>
To: lazarus at miraclec.com <lazarus at miraclec.com>
Date: Thursday, October 21, 1999 12:04 AM
Subject: Re: [lazarus] mwEdit Problems


>I came upon two problems in the cbUtils unit  when working to compile
mwEdit
>that I don't know exactly how to fix. I don't know if they are compiler
bugs or
>something else. Can someone take a look at the following and tell me how I
can
>fix it for FPC?
>
>In the cbUtils unit, are the following definitions:
>
>  TSpeedListObject = class
>  protected
>    FName: String;
>    FSpeedList: TSpeedStringList;
>    procedure SetName(const Value: String); virtual;
>  public
>    Property Name: String read FName write SetName;
>    {$IFDEF MWE_FPC}
>    constructor create(aname: string);
>    {$ELSE}
>    constructor create(name: string);
>    {$ENDIF}
>    destructor destroy; override;
>    property SpeedList: TSpeedStringList read FSpeedList write FSpeedList;
>  end;
>
>  PSpeedListObjects = ^TSpeedListObjects;
>  TSpeedListObjects = array [0..0] of TSpeedListObject;
>
>  TSpeedStringList = class
>  private
>    function GetText: string;
>    procedure SetText(const Value: string);
>  Protected
>    FOnChange: TNotifyEvent;
>    SumOfUsed: array [0..NbSubList-1] of integer;
>    datasUsed: array [0..NbSubList-1] of integer;
>    datas: array [0..NbSubList-1] of PSpeedListObjects;
>    lengthDatas: array [0..NbSubList-1] of integer;
>    procedure Changed; virtual;
>    function Get(Index: Integer): string; virtual;
>    function GetObject(Index: Integer): TSpeedListObject;
>    function GetCount: integer;
>    Function GetStringList: TStrings;
>    Procedure SetStringList(const value: TStrings);
>  public
>    Procedure NameChange(const obj: TSpeedListObject; const NewName:
String);
>    Procedure ObjectDeleted(const obj: TSpeedListObject);
>
>    destructor Destroy; override;
>    constructor create;
>    function Add(const Value: TSpeedListObject): Integer;
>    procedure Clear;
>    function Find(const name: String): TSpeedListObject;
>    property OnChange: TNotifyEvent read FOnChange write FOnChange;
>    property Objects[Index: Integer]: TSpeedListObject read GetObject;
>    property Strings[Index: Integer]: string read Get; default;
>    property count: integer read GetCount;
>    Property StringList: TStrings read GetStringList write SetStringList;
>    property text: string read GetText write SetText;
>  end;
>
>
>Then the function below implements the Add function.
>
>
>
>function TSpeedStringList.Add(const Value: TSpeedListObject): Integer;
>var
>  crc: integer;
>  i: integer;
>begin
>  crc:= StringCrc(Value.Name) mod (High(Datas)+1);
>  if DatasUsed[crc]=lengthDatas[crc] then begin
>    {$IFDEF MWE_FPC}
>    ReallocMem(datas[crc], DatasUsed[crc],
>(lengthDatas[crc]*2+1)*SizeOf(datas[1][0]));
>    {$ELSE}
>    ReallocMem(datas[crc], (lengthDatas[crc]*2+1)*SizeOf(datas[1][0]));
>    {$ENDIF}
>    lengthDatas[crc] := lengthDatas[crc]*2+1;
>  end;
>  Datas[crc][DatasUsed[crc]]:= Value;
>  result:= SumOfUsed[crc]+DatasUsed[crc];
>  inc(DatasUsed[crc]);
>  for i:= crc+1 to High(SumOfUsed) do
>    inc(SumOfUsed[i]);
>  Value.SpeedList:= Self;
>end;
>
>
>The first problem I had was in the constructor of the TSpeedListObject. It
>passes in a parameter called "name". There is also a property called name.
When
>I tried to compile this, it had a problem because the compiler confused the
>parameter with the property and gave me an error stating that Name was
already
>defined. I put in the MWE_FPC defines as above and renamed it to "aname"
and it
>compiles fine. Is this a possible bug in the compiler, or is it a bug in
Delphi
>that allows it?
>
>The second problem is in the implementation of the Add method above. The
>following line
>

looks like some kind of pointer array that is not being parsed correctly you
may try to rewrite it like
something like this


     myint := DatasUsed[crc]



>    Datas[crc][myint]:= Value;
>
>causes the following compiler error
>
>Incompatible types: got "TSPEEDLISTOBJECT" expected "TSPEEDLISTOBJECTS"
>
>It looks to me like it is trying to do some sort of two dimensional array
or
>something. I don't understand what this is doing, so I don't know how to
fix
>it. Can someone explain what this is doing and how I an fix it to work in
FPC?
>
>Again, if you don't understand my message, just try compiling the
cbUtils.pas
>unit in the mwEdit directory. I am committing the changes I have made to
CVS so
>it will have the same code I am working on.
>
>
>Curtis
>
>_________________________________________________________________
>     To unsubscribe: mail lazarus-request at miraclec.com with
>                "unsubscribe" as the Subject
>    archives at http://www.miraclec.com/list_archives/lazarus
>






More information about the Lazarus mailing list