[lazarus] mwEdit Problems

Kevin Berry kevinbe71 at yahoo.com
Fri Oct 22 01:19:31 EDT 1999


Hi,

I'm new to this mailing list, but from my experience
with Delphi I think I can answer the first question...

In Delphi the "name" parameter takes preference over
the property because the scope rules state that a
parameter or local variable takes preference over
class properties or member variables.  FPC should be
allowing this to compile and you would then use
self.name inside the procedure to reference the
property.  HTH.

BTW, I was browsing the web site and have been waiting
for it to be updated and it hasn't been for a while...

Cheers,
Kevin.

--- Curtis White <osiriz at teleport.com> wrote:
> 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?


=====

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com






More information about the Lazarus mailing list