Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify Delphi StringList object is created or not

I have declared variable of TStringList in private section. In a button click event I want to access that TStringList object.

sVariable:= TStringList.Create;
sVariable.add('Test1');

Now whenever i click on that button each time its newly created and memory is allocated to that variable. Is there any property/function using which we can determine object is created for that variable or not and it will not give the access violation error also?

like image 581
Nalu Avatar asked Dec 07 '22 19:12

Nalu


1 Answers

if not Assigned(sVariable) then
  sVariable:= TStringList.Create;
sVariable.add('Test1');
like image 122
David Heffernan Avatar answered Mar 27 '23 06:03

David Heffernan