Connecting to Simulator Automation Server (version 9)
Once the Type Library or COM functions have been included in your programming environment, the Simulator Automation Server can be handled as any other object in your code. The method for assigning and connecting to the Simulator Automation Server can vary depending on the programming environment used, but the idea is basically the same. You define a variable in your program to point to the server object, which is called SimulatorAuto. If the Type Library was imported properly, you should have full access to the SimulatorAuto object and its defined functions. Again, the procedure for creating the object and connecting to SimulatorAuto may vary for different programming languages. Check the help for your programming environment on connecting to COM or Automation servers.
Examples
The following examples are just a few specific examples for certain programming media. The procedure may be different for other programming media not listed. In addition, a procedure given for a certain type of programming media may be one variation from several possible procedures for accomplishing the same task.
Borland Delphi 5
- Add pwrworld_TLB to the uses section of your unit.
- Declare a variable globally or as part of another object: A : ISimulatorAuto.
- Initialize the variable: A := nil.
- To connect to the Simulator Automation Server, create the connection: A := CoSimulatorAuto.create.
- Perform function calls to the Simulator Automation Server: A.SomeFunction(parameters).
- To close the connection to the Simulator Automation Server, remove the reference by again setting: A := nil.
Microsoft Visual Basic
- Declare a variable globally or as part of another object or function: Public A As SimulatorAuto.
- To connect to the Simulator Automation Server, create the connection: Set A = New SimulatorAuto.
- Perform function calls to the Simulator Automation Server: A.SomeFunction parameters.
- To close the connection to the Simulator Automation Server, remove the reference: Set A = Nothing.
Microsoft Visual C++
- Declare a variable globally or as part of another object or function: IsimulatorAutoPtr *A.
- Declare a variable globally or as part of another object or function: CLSID clsid.
- Declare a variable globally or as part of another object or function: HRESULT hr.
- Obtain the class identifier (clsid) with the following command: hr = CLSIDFromProgID(L"pwrworld.SimulatorAuto", &clsid).
- Initialize variable A: A = new IsimulatorAutoPtr.
- To connect to the Simulator Automation Server, create the connection: hr = A>CreateInstance(clsid, NULL, CLSCTX_SERVER).
- Perform function calls to the Simulator Automation Server: A.SomeFunction(parameters).
- To close the connection to the Simulator Automation Server, release the reference: hr = A>Release().