
Chapter 5: Creating an iTool 105
iTool Developer’s Guide Creating an iTool Launch Routine
turn, hold the actual data used by the iTool. To create a data object, use the
OBJ_NEW function:
oData
= OBJ_NEW('IDLitData',
vData
, TYPE =
dataType
, $
NAME =
dataName
)
where oData is a named variable that will hold the object reference to the data object,
vData is an IDL variable containing the actual data, dataType is a string specifying
the iTool data type of the data held by the object, and dataName is a string that will
be used by the iTool user interface to refer to the data object. See “iTool Data Types”
on page 54 for additional information on iTool data types.
For example, if you are creating a data object to hold the Y vector of a two-
dimensional plot, you might use the following code:
oPlotY = OBJ_NEW('IDLitData', yData, TYPE = 'IDLVECTOR', $
NAME = 'Y data')
Here, the data that make up the Y vector are contained in the variable yData. After a
data item has been created, it must be added to the parameter set object. Continuing
our example, the following code adds the oPlotY data object to the oPlotData
parameter set object, assigning the parameter name
'Y data':
oPlotData->Add, oPlotY, PARAMETER_NAME='Y data'
See Chapter 3, “Data Management”, and “IDLitData” (IDL Reference Guide) for
details.
Example
For an example iTool launch routine that creates and populates a parameter set object,
see “Example: Simple iTool” on page 108.
Handling Errors
The error-handling requirements of your iTool launch routine will depend largely on
the type of data processing you perform. In general, your goal should be to clean up
any objects or pointers your routine creates, display an error message to the user, and
return to the calling routine. It is beyond the scope of this chapter to discuss IDL’s
error handling mechanisms in detail; for more information see Chapter 8,
“Debugging and Error-Handling” (Application Programming).
iTool launch routines included in the IDL distribution handle errors by placing a
block of IDL code that looks like the following at the beginning of the routine:
ON_ERROR, 2
CATCH, iErr
IF (iErr NE 0) THEN BEGIN