Scripter.ExecuteSubroutine question


I have a script project which has several units.
Each unit has it's own routines.

I want to use Scripter.ExecuteSubroutine funtion to execute a routine in a given unit.

This works.
But only if the tab of the unit where the routine is implemented is selected.

Is it possible to ExecuteSubroutine without selecting the unit?

If not. How can I make a unit the active one and then ExecuteSubroutine?


Have a nice day.

Some more info.

I want to be able to do the following.

In unit1 I have a routine with the name routineA
In unit2 I have a routine with the name routineB

In the main unit I have the routine below

procedure RunNtimes(RoutineName: string; N: Integer)
// the code that will run the routine N times

and then call
RunNTimes('routineA', 5);
RunNTimes('routineB', 3);

The Scripter.ExecuteSubroutine executes a subroutine in current script. You need to specify the current script using the CurrentScript property:

Scripter.CurrentScript := MyScript;

Of course you need to gather MyScript somehow, if you added your scripts, save a reference to them. As for executing routines from script itself from the name, it's not possible unfortunately.