1

I'm facing a problem I can't find the workaround... I have a script which take some parameter data before execution. When I run it my code looks like:

Exec := FProgram.CreateNewExecution;
Exec.BeginProgram;

Exec.Info.ValueAsString['varName'] := 'varValue';

Exec.RunProgram(0);
Exec.EndProgram;

It runs just fine. But if I want to debug the script I do something like this:

Exec := FProgram.CreateNewExecution;
Exec.BeginProgram;
Exec.Info.ValueAsString['varName'] := 'varValue';

Debugger.BeginDebug(Exec);
Debugger.EndDebug;

Being Debugger a TdwsDebugger class, I get "runtime error: script is already running". If I don't assign variables values before debugging everything is ok.

Any hints?

  • Just a guess: move the parameter data code line after BeginDebug. Or remove BeginProgram line. Or read the documentation :-) :-) – fpiette Sep 30 '20 at 15:09
  • Hi fpiette, I've already tried that. When debug starts BeginDebug does not end until the scripts ends. – Adrian De Armas Sep 30 '20 at 15:25

1 Answers1

1

I managed to solve it using the TDelphiWebScript component events. Using OnExecutionStarted does not work either. I modified the code and added OnAfterExecutionStarted event, then I added the variables on the new event and everything is ok now.