std-save-undo, std-restore-undo | ![]() |
These two complementing functions are used in error handling to save the current UNDO settings on init and restore the old state on restore.
STD-SAVE-UNDO returns a number which is the same as the state of the sytemvariable UNDOCTL. Undo may be grouped or not, On or Off, Auto or undo only one command.
STD-RESTORE-UNDO takes the number returned by STD-SAVE-UNDO and sets UNDO according to this number.
UNDOCTL bitcode
0 UNDO is turned off 1 UNDO is turned on 2 Only one command can be undone 4 Turns on the Auto option 8 A group is currently active
Both functions are normally used by the error handling pair (STD-VAR-INIT '((:UNDO))) and (STD-VAR-RESTORE) resp. (STD-VAR-PUSH alist) and (STD-VAR-POP) if the state of UNDO is used inside the user function, to save and restore the old setting, esp. on user-breaks or errors.
Note
STD-ENABLE-UNDO and STD-DISABLE-UNDO are also defined to disable UNDO at all as well as AI_UNDO_PUSH and AI_UNDO_POP to group commands and let lisp functions behave like one AutoCAD command.
(std-var-init '((:UNDO))) ... (progn
(std-disable-undo)
; do unsafe stuff here
... (std-enable-undo) ) ... (std-var-restore)
undoctl: an integer number defining the state of the sytemvariable UNDOCTL.
STD-SAVE-UNDO returns a number.
The return value of STD-RESTORE-UNDO is nil.
STD-RESTORE-UNDO changes the current VIEWPORT settings.
(std-require 'STDTBL)
Defined in STDTBL