
168 Chapter 7: Creating an Operation
Creating a New Generalized Operation iTool Developer’s Guide
Note
Because iTool operations are invoked by the user’s interactive choice of an item
from a menu, they generally do not accept any keywords of their own.
The function signature of an Init method for an operation generally looks something
like this:
FUNCTION
MyOperation
::Init, _REF_EXTRA = _extra
where MyOperation is the name of your operation class.
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 operation class Init method should call the Init method of any required
superclass. For example, if your operation class is based on an existing operation, you
would call that operation’s Init method:
success = self->
SomeOperationClass
::Init(_EXTRA = _extra)
where SomeOperationClass is the class definition file for the operation on which
your new operation is based. The variable
success contains a 1 if the initialization
was successful.
Note
Your operation 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->
SomeOperationClass
::Init(_EXTRA = _extra) EQ 0) THEN $
RETURN, 0