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?

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

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Using OnExecutionStarted does not work either. I modified the code and added OnAfterExecutionStarted event.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.