Forum Discussion

pjaju's avatar
pjaju
Occasional Contributor
16 years ago

Run functions from various scripts

I have created 10 script files and all of them contains one subroutine (commonly named as Run_This in all 10 scripts). I have crated another script file which references to all of these scripts (using USEUNIT). Now I want to run them in a sequence - so the script will look something like the following:



Sub Main()

Call Unit1.Run_This

....

....

....

Call Unit10.Run_This

End Sub



So except for the script file names, the command is same. Is there a way where I can run all these scripts in a loop -- something like:

For i = 0 to 9

' ScriptFileName = "Unit" & i

' Call ScriptFileName.Run_This

Next

2 Replies


  • Hi,





    Use Eval.

    ...

    For i = 0 to 9

     FuncName = "Unit" & i & ".Run_This"

     Call Eval(FuncName)

    Next

    ...