
Chapter 7: Creating an Operation 175
iTool Developer’s Guide Creating a New Generalized Operation
oTargets[i]->GetProperty, STYLE = styleIndex
; Add the value to the command object
void = oCmd->AddItem('OLD_STYLE', styleIndex)
; Add the command object to the command set
oCmdSet->Add, oCmd
ENDFOR
RETURN, 1
END
Discussion
The ExampleOp operation RecordInitialValues method simply loops through the
supplied list of target objects, creating a new IDLitCommand object for each. We set
the TARGET_IDENTIFIER property for each command object. Next, we retrieve the
value of the STYLE property for each target object and add it to the command object
as an Item. Finally, we add each command object to the supplied IDLitCommandSet
object.
Creating a RecordFinalValues Method
The operation class RecordFinalValues method is responsible for recording the
appropriate “after” values from the specified objects in the provided
IDLitCommandSet object. The values recorded depend entirely on the operation
being performed.
Example RecordFinalValues Method
The following example code shows a simple RecordFinalValues method for the
ExampleOp operation. The new value of the STYLE property of each target object is
recorded in the appropriate IDLitCommand object retrieved from the command set.
FUNCTION ExampleOp::RecordFinalValues, oCmdSet, oTargets, idProp
; Loop through the target objects and record the value of the
; STYLE property.
FOR i = 0, N_ELEMENTS(oTargets)-1 DO BEGIN
; Retreive the appropriate command object from the
; command set.
oCmd = oCmdSet->Get(POSITION = i)
; Get the value of the STYLE property
oTargets[i]->GetProperty, STYLE = styleIndex
; Add the value to the command object
void = oCmd->AddItem('NEW_STYLE', styleIndex)
ENDFOR