I’m trying to use the LotusScript “Execute” statement to dynamically load a script library (which uses other libraries in turn) and run a Sub in the library, and getting weird behaviour with Initialize Subs.
The basic problem is any code I put in an Execute statement is running before the Initialize Subs of any script libraries used in the Execute statement. This is the opposite to what normally occurs without using Execute.
My actual script libraries have a few thousand lines, but here’s a very basic example illustrating the problem…
Script lib 1 - “BaseLib” - contains this code:
Sub Initialize
Print "Base lib Initialize"
End Sub
Script lib 2 - “SecondLib” - contains this code:
Use “BaseLib”
Sub Initialize
Print "Second lib Initialize"
End Sub
An agent contains this code:
Sub Initialize()
Execute {Use "SecondLib"
Sub Initialize
Print "Temporary module Initialize"
End Sub}
End Sub
Running the agent produces this output:
Temporary module Initialize
Base lib Initialize
Second lib Initialize
In contrast, if the agent does not use Execute, but instead directly uses “SecondLib”, the output appears as follows:
Base lib Initialize
Second lib Initialize
Agent Initialize
Is there any simple way to ensure that, when using Execute, Initialize subs are called in the same order as when not using Execute?