Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Using global objects in class methods
Thu, Sep 17 2015 3:32 PMPermanent Link

Christian Kaufmann

Hi,

I have this code:

class function TBSStorage.GetLocaleAsString(const AName: String; const ADefault: String = ''): String;
begin
 if LocalStorage.Exists(AName)
   then Result := LocalStorage.Items[AName]
   else Result := ADefault;
end;

This worked fine in EWB 1. Now I get a compiler error:

[Error] BSCore.wbs (215,19): Cannot access the Exists(AName) instance member from within a class method

I'm not sure, what part of my code is not allowed anymore in EWB 2?

cu Christian
Fri, Sep 18 2015 6:20 AMPermanent Link

Matthew Jones

Christian Kaufmann wrote:

>
> class function TBSStorage.GetLocaleAsString(const AName: String;
> const ADefault: String = ''): String; begin
>   if LocalStorage.Exists(AName)
>     then Result := LocalStorage.Items[AName]
>     else Result := ADefault;
> end;
>

I have similar code now, so my first thought is to make sure the unit
that defines LocalStorage is included in your uses clause.

--

Matthew Jones
Fri, Sep 18 2015 10:23 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Christian,

<< This worked fine in EWB 1. Now I get a compiler error: >>

It's a bug.  I'll have a fix for this in 2.02.

Tim Young
Elevate Software
www.elevatesoft.com
Image