Object creation and interfaces

To talk to COM objects you must use interfaces. The ECI and EPI COM libraries provide two interfaces per COM class.

The first interface is called IDispatch and is provided to support old Visual Basic applications and VBScript. A second interface, a Custom interface, is also provided for use by Visual Basic. This interface is faster than the IDispatch interface and it is recommended that you use this interface with Visual Basic. Each COM class provides an IDispatch interface and a Custom interface.

Visual Basic provides more than one way to create a COM object and select the interface to talk to that object. To create an object there are the CreateObject function and the New function. It is recommended that you use the New function to create objects in Visual Basic.

VBScript is simpler. It provides only one way to create an object, the CreateObject function, and you must use the IDispatch interface.

The following are some examples of creating COM objects
Set eci = CreateObject("Ccl.ECI")
Set eci = New CcloECI 
Set connection = CreateObject("Ccl.Connect")
Set connection = New CcloConn

Note the two ways you can request the object class. When using CreateObject you specify a string called the Programmatic ID or ProgID for short. When using the New function you specify the Class name that is registered in the type library.

When using Visual Basic you have the choice of which interface you want to use. If you DIM your variable as Object, then you select the IDispatch interface. If you DIM your variable as the Class name then you will select the custom interface. To create a terminal object in Visual Basic you would use the code:

Figure 1. Creating a terminal object in Visual Basic
Dim Terminal as CclOTerminal 
Set Terminal = New CclOTerminal
or you can combine the above into a single statement if you wish
Dim Terminal as New CclOTerminal
When using VBScript, VBScript will automatically select the IDispatch interface for you. For example to create a terminal Object in VBScript you would use the code
Figure 2. Creating a terminal Object in VBScript
Dim Terminal 
Set Terminal = CreateObject("Ccl.Terminal")
It is recommended that you:

No matter which interface you select or how the object is created, you use the objects identically in your program.


Information Information

Feedback


Timestamp icon Last updated: Tuesday, 19 November 2013


https://ut-ilnx-r4.hursley.ibm.com/tg_latest/help/topic/com.ibm.cics.tg.doc//progde/cclaovc1.html