• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

create a var in a unit and free again using begin end block

I know there is a solution to create a var and init at program start and free adain at close/ terminiate event  with some lines of code between the begin end block of a unit
0
BdLm
Asked:
BdLm
1 Solution
 
Geert GOracle dbaCommented:
something like this ?


unit uTest;
 
interface
 
uses Classes;
 
procedure AddTest(aText: string);
procedure DelTest(aText: string);
 
implementation
 
var mList: TStrings;
 
procedure AddTest(aText: string);
begin
  mList.Add(aText);
end;
 
procedure DelTest(aText: string);
begin
  mList.Delete(mList.IndexOf(aText));
end;
 
initialization
  mList := TStringList.Create;
finalization
  FreeAndNil(mList);
end.

Open in new window

0
 
BdLmAuthor Commented:
thanks I forgot this one ,
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now