Imagine this Script:
var s = TStrings.Create;
s.Add('Line 1');
s.Add('Line 2');
procedure MyProc;
begin
if s.count = 2 then
// ...
end;
When the Script runs it creates the variable "s". Now I'd like to call "MyProc" after the script is done:
...
Exec := Program.CreateNewExecution;
Exec.BeginProgram;
Exec.RunProgram(0);
if Exec.ProgramState in [psRunning, psRunningStopped] then
begin
Func := Exec.Info.Func['MyProc'];
Func.Call([]);
Exec.EndProgram;
end;
I get an error accessing "s" from MyProc. I assume that the garbage collector of DWS already freed the stringlist. Is this right? Can I do something to keep "s" alive?