Using OLE or DDE Execute functionality to run a simulation.
1. Are there any caveats to how I can use the RunSimulation, PauseSim, and ResumeSimulation functions?
These functions are not recommended for use via OLE automation or DDE Execute messages at all. These functions were developed before the External Scripting functionality was fully developed, and they do not work as well in this context as the ExecuteMenuCommand function. This function acts exactly as if you have selected the specified command from the menu bar and will perform better with the external control methods. The ExecuteMenuCommand function takes one argument, the command number. These numbers are defined in the Technical Reference.
2. Should I use a different modeling technique if I am running a simulation that basically finishes instantly versus running a simulation that will run for longer and want to control interactively?
There is a difference in how you should set up your code in these two cases.
If the simulation is going to complete instantly and/or you are not interested in sending other commands to ExtendSim while the simulation is running, you can just send the executeMenuCommand(6000) to ExtendSim without a worry.
If, however, you are interested in running a longer simulation, and you want to be able to pause and resume it or get data while the simulation is running, you should use the IPCServerAsync(TRUE); function. This function specifies to ExtendSim that the following Execute control action should execute asynchronously, not synchronously. A synchronously executed instruction will execute immediately and the application that sent the command will wait for the instruction to complete before it continues its execution. An async command, on the other hand, will return immediately allowing the application to continue on with other things while the simulation runs. The sequence of instructions you should execute in this case would be as follows:
These should be sent as three different execute messages. It is important to send the final IPCServerAsync(FALSE) and not to send any other Async messages while the simulation is running, as ExtendSim doesn't allow multiple asynchronous messages to be processed simultaneously.