• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • 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 GruwezOracle 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

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

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