ITT Rule IDL Version 7.0 ユーザーズマニュアル

ページ / 430
236
Chapter 9: Creating a File Reader
Creating a New File Reader
iTool Developer’s Guide
return the value 1 if the initialization steps are successful, or 0 otherwise
Definition of the Init Function
Begin by defining the argument and keyword list for your Init method. The argument 
and keyword list defines positional parameters (arguments) accepted by your method, 
defines any keywords that will be handled directly by your method, and specifies 
whether keywords not explicitly handled by your method will be passed through to 
other routines called by your method via IDL’s keyword inheritance mechanism. The 
function signature for an Init method for a file reader generally looks something like 
this:
FUNCTION 
MyReader::Init, MYKEYWORD1 = mykeyword1, $
MYKEYWORD2 = mykeyword2, ..., _REF_EXTRA = _extra
where MyReader is the name of your file reader class and the MYKEYWORD 
parameters are keywords handled explicitly by your Init function. 
Note
Always use keyword inheritance (the _REF_EXTRA keyword) to pass keyword 
parameters through to any called routines. (See 
Application Programming) for details on IDL’s keyword inheritance mechanism.)
Superclass Initialization
The file reader class Init method should call the Init method of any required 
superclass. For example, if your file reader is based on an existing file reader class, 
you would call that class’ Init method:
success = self->
SomeFileReaderClass::Init(_EXTRA = _extra)
where SomeFileReaderClass is the class definition file for the file reader on which 
your new file reader is based. The variable 
success
 will contain a 1 if the 
initialization was successful.
Note
Your file reader 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