
94 Chapter 5: Creating an iTool
Creating a New iTool Class iTool Developer’s Guide
Note
Always use keyword inheritance (the _REF_EXTRA keyword) to pass keyword
parameters through to any called routines. See “Keyword Inheritance” (Chapter 5,
Application Programming) for details on IDL’s keyword inheritance mechanism.
Superclass Initialization
The iTool class Init method should call the Init method of any required superclasses.
For example, if your iTool is based on an existing iTool, you would call that tool’s
Init method:
success = self->
SomeToolClass
::Init(_EXTRA = _extra)
where SomeToolClass is the class definition file for the iTool on which your new
iTool is based. The variable
success contains a 1 if the initialization was successful.
Note
Your iTool class may have multiple superclasses. In general, each superclass’ Init
method should be invoked by your class’ Init method.
Error Checking
Rather than simply calling the superclass Init method, it is a good idea to check
whether the call to the superclass Init method succeeded. The following statement
checks the value returned by the superclass Init method; if the returned value is 0
(indicating failure), the current Init method also immediately returns with a value of
0:
IF (self->
SomeToolClass
::Init(_EXTRA = _extra) EQ 0) THEN RETURN,
0
This convention is used in all iTool classes included with IDL. W strongly suggest
that you include similar checks in your own class definition files.
Keywords to the Init Method
Properties of the iTool class can be set in the Init method by specifying the property
names and values as IDL keyword-value pairs. In addition to any keywords
implemented directly in the Init method of the superclass on which you base your
class, the properties of the IDLitTool class are available to any iTool class. See
“IDLitTool Properties” (IDL Reference Guide).