A SERVICE OF

logo

164 Chapter 7: Creating an Operation
Creating a New Data-Centric Operation iTool Developer’s Guide
Creating an UndoExecute Method
The operation class’ UndoExecute method is called when the user undoes an
invocation of the operation and the REVERSIBLE_OPERATION property is set on
the operation object. (See “Operations and the Undo/Redo System” on page 150 for
details on how undo and redo are handled in different situations.) The UndoExecute
method must reverse the effect of the Execute method.
The actual processing performed by the UndoExecute method depends entirely on
the operation.
Example UndoExecute Method
The following example code shows a simple UndoExecute method for the
ExampleDataOp operation, which reverses the operation of the Execute method.
FUNCTION ExampleDataOp::UndoExecute, data
; If byte data then offsets are 0 and 255, otherwise
; use data minimum and maximum.
offsetMax = (SIZE(data, /TYPE) eq 1) ? 255b : MAX(data)
offsetMin = (SIZE(data, /TYPE) eq 1) ? 0b : MIN(data)
data = offsetMax - TEMPORARY(data) + offsetMin
RETURN, 1
END
Discussion
When the user undoes an invocation of our ExampleDataOp operation, the iTool
system supplies the data that were computed by the Execute method when the
operation was invoked. Our UndoExecute method then reverses the original
operation.