[Lazarus] global items in TApplication
Martin
lazarus at mfriebe.de
Sun Sep 15 16:57:59 CEST 2013
On 15/09/2013 15:20, Marc Santhoff wrote:
> It's not in question how to implement global objects. Some are
> singletons by design and others are not in code but work like they were,
> because the only place the constructor is (allowed to be) called is the
> inittialization section.
>
> The qeustion is where to store those objects.
1)
global war, but in implementation
interface
procedure GetFoo: TFoo;
property Foo read GetFoo;
implementation
var TheFoo: TFoo = nil;
procedure GetFoo: TFoo;
begin
if TheFoo= nil then TheFoo:= TFoo.Create;
REsult := TheFoo;
end;
Or, in the GetFoo
implementation
procedure GetFoo: TFoo;
const TheFoo: TFoo = nil;
begin
if TheFoo= nil then TheFoo:= TFoo.Create;
REsult := TheFoo;
end;
More information about the Lazarus
mailing list