Processing Ispec Messages

Refer to the Unmanaged C++ Example and the Managed .NET C# Example for more information.

The Connect() and Disconnect() methods are used solely to maintain ‘state’. They mark the beginning and end of a session. When you call the Connect() method, a unique integer session ID is returned.

In subsequent calls to CreateInstance() and ProcessMsg() you must pass the session ID so that the state for that session is restored for that message. Calling Disconnect() with the session ID ends the session and remove your state from the system.

When you call Connect(), you can also pass in a pointer to an IComms interface. This interface points to an object in your own address space that is used to receive asynchronous messages and accepts. If you pass in NULL for this parameter, then you will not receive any messages or accepts.

If you don t want or don t need to maintain state, you can simply call the ProcessMsg() method passing in 0 for the session id. In this case, you do not need to call Connect() or Disconnect(), but no state is maintained between transactions. You will also not get any messages or accepts (since the interface for receiving these is passed in via the Connect() method).

CreateInstance() can now be called to create an instance of an ispec, including the execution of the ispec’s Construct() method. A GenericClass object for this ispec is returned containing field values as initialized by the Construct() logic.

Your can now call the SetValue() and/or SetArrayValue() methods to set values into individual fields. These methods are called once for each field that needs to be set with a value.

The ProcessMsg() method is now called to perform the ispec transaction. The GenericClass object that you have previously defined is passed as a parameter. This performs the full ispec cycle including automatic and user-defined logic, such as automatic editing, Prepare() logic, automatic lookups, Main() logic, etc. A GenericClass object representing the output ispec is passed as a return value.

Values from the returned ispec fields can be retrieved via calls to GetValue() and/or GetArrayValue().

Any messages generated by the ispec are returned in a messages array. The number of messages can be retrieved via GetNumMessages(). The normal ispec status-line message is always the first message in the array. Individual messages can be retrieved by calling GetMessage(), passing the index (zero-based) of the required message as a parameter.