|
IDL Connectivity Bridges: COM Object Creation |
|
The COM CreateObject method creates an instance of an underlying IDL object and calls its Init method with any specified parameters (see CreateObject for details). Through this object instance, you have access to the properties and methods of the object as well as the underlying IDL process.
The following samples rely upon an IDL object named idlexfoo__define.pro containing the following code:
; The Init method expects three parameters:
; a string, a 32-bit long, and an array which has
; 2 rows & 3 columns, containing 32-bit long values.
; The ::Init method can also be called without any parameters.
FUNCTION idlexfoo::Init, parmStr, parmVal, parmArr, _EXTRA=e
IF (N_ELEMENTS(parmStr) EQ 1) THEN BEGIN
IF ( SIZE(parmStr,/type) NE 7 ) THEN BEGIN
PRINT, 'IDLexFoo::Init, parmStr is not a STRING'
HELP, parmStr
RETURN, 0
ENDIF
ENDIF
IF (N_ELEMENTS(parmVal) EQ 1) THEN BEGIN
IF ( (SIZE(parmVal,/type) NE 3) ) THEN BEGIN
PRINT, 'IDLexFoo::Init, parmVal is not a LONG'
HELP, parmVal
RETURN, 0
ENDIF
ENDIF
nElms = N_ELEMENTS(parmArr)
IF (nElms GT 0) THEN BEGIN
IF ( (nElms NE 6) OR (size(parmArr,/type) NE 3) ) THEN BEGIN
PRINT, 'IDLexFoo::Init, parmArr is not a ARR(3,2) of
LONG)'
HELP, parmArr
RETURN, 0
ENDIF
ENDIF
RETURN, 1
END
; Object definition.
PRO idlexfoo__define
; Create [col, row] 32-bit long array.
initArr = LONARR(3,2)
struct = {idlexfoo, $
parmStr: '', $
parmVal: 0L, $
parmArr: initArr $
}
END
You will need to create the necessary wrapper object files by using the Export Bridge Assistant to generate them. Once you have created the object definition file, idlexfoo__define.pro, complete the following steps:
New Project
COM and browse to select the idlexfoo__define.pro file. Click Open to load the file into the Export Assistant.
| Note Export Bridge Assistant details are available in Using the Export Bridge Assistant. Refer to that section if you need more information about the following steps. |
Save project. Accept the default name and location or make changes as desired.
Build object. The Build log panel shows the results of the build process. For a nondrawable object, .tlb and .dll files (named based on the object name) are created in the Output directory.
dll using regsvr32 idlexfoo.dll. See COM Registration Requirements for details if needed.See the language-specific section for information on how to create this object in your application:
IDL Online Help (March 06, 2007)