How Undo Works
- Last UpdatedJan 28, 2025
- 2 minute read
Every time you select an undo operation an entry is taken off the undo stack. The state saved in this transaction is restored, and the transaction object is placed on the redo stack.
When the undo stack is empty, then the Undo button and the Undo menu option will be greyed out indicating that there are no operations remaining that can be undone.
If the operation of undo involves moving into or out of model editing mode, then the switch into that mode will happen automatically, and the model editor button and menu option will reflect the change.
The selection set and handle appropriate to the editing operation that was being used will also be restored.
There are also a number of ways that you can perform an undo:
-
By clicking on the Undo button on the appropriate toolbar.
-
By selecting the Undo option on the Edit pulldown menu on the main toolbar.
-
By entering the command UNDODB n where n indicates how many steps are to be undone.
The undo stack is automatically cleared after a SAVEWORK or GETWORK.
A similar process to the one described above occurs for redo.
When a transaction is taken off the redo stack, it is put back onto the undo stack.
If you perform any operation that changes the database after doing an undo, then the redo stack will be cleared.
Refer to Undo and Redo for controlling the undo stack from user defined Programmable Macro Language (PML).
|
MARKDB 'comment' |
Set a Database mark. Multiple marks may be set. |
|
UNDODB |
Undo database to last mark. Multiple undos are allowed. |
|
REDODB |
Redo to next mark. Multiple Redos are allowed. A redo is only valid after an UNDO. Any database change after an UNDO invalidates a REDO. |
The list of marks can be obtained from PML function MARKDB.
Example
AREA 0
MARKDB 'First Mark'
AREA 100
MARKDB 'Second Mark'
AREA 200
MARKDB 'Third Mark'
AREA 300
!MARKS = MARKDB
Q VAR !MARKS
UNDODB
Q AREA - value will be 200
UNDODB
Q AREA - value will be 100
UNDODB
Q AREA - value will be 0
REDODB
Q AREA - value will be 100
REDODB
Q AREA - value will be 200
AREA 99
UNDODB
Q AREA - value will be 200
REDODB
Q AREA - value will be 99
The system will always create an initial mark the first time the database is changed.