Is there a need to cancel active commands in custom *error*?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I just upgraded to 2016 from 2012.
In prior versions up thru 2012 I had this line in my standard custom *error* function to cancel any active commands that was used by most of my apps.
(while (> (getvar "CMDACTIVE") 0)(command))
Now with 2016 I need to use the (command-s ...) function in the *error* but calling just (command-s) without any arguments does not cancel active command the way (command) did from what I have read and tested.
How do you handle canceling any active commands in 2015+? Or is it even need anymore?
By the testing I have done, it seems that any active command is canceled on error anyway. But I have not test every possible case. The main reason in the past for canceling active commands was I would do an "undo" "begin" when app started and an "undo" "end" when exiting or on error (along with resetting other misc things) that I think would fail if another command was active (it's been awhile so I forget now).
Below is the standard functions used by most of my code for reference. The line above in question is currently commented out as it fails.
;;;* * * * * * * * * * * * * ERROR FUNCTIONS * * * * * * * * * * * * * * *
;;;
;;; hgc_error
;;;
;;; General *ERROR* Handling function
;;; usage - (setq *error* hgc_error)
(defun hgc_error (msg) ;standard error function
(hgc_reset_system)
)
;;;=======================================================================
;;;
;;; hgc_save_system
;;;
;;; Save existing drawing editor settings
;;; use as first function in program
;;; after called, make setvar changes and set *error* to hgc_error
(defun hgc_save_system () ;saved existing system settings
(setq hgc_saved_err *error*
hgc_highlight (getvar "HIGHLIGHT")
hgc_osmode (getvar "OSMODE")
hgc_orthomode (getvar "ORTHOMODE")
hgc_autosnap (getvar "AUTOSNAP")
hgc_aperture (getvar "APERTURE")
hgc_dimzin (getvar "DIMZIN")
hgc_textstyle (getvar "TEXTSTYLE")
hgc_expert (getvar "EXPERT")
hgc_cmdecho (getvar "CMDECHO")
) ;setq
(setvar "CMDECHO" 0)
(command-s ".UNDO" "BEGIN") ;05-16-16 Changed to command-s
(setvar "CMDECHO" hgc_cmdecho)
)
;;;=======================================================================
;;;
;;; hgc_reset_system
;;;
;;; Resets drawing editor settings
;;; use at end of program
(defun hgc_reset_system () ;reset existing system settings
(setq *error* hgc_saved_err)
;(while (> (getvar "CMDACTIVE") 0)(command)) ;cancel any active commands **********CODE IN QUESTION************
(setvar "textstyle" hgc_textstyle)
(setvar "HIGHLIGHT" hgc_highlight)
(setvar "OSMODE" hgc_osmode)
(setvar "ORTHOMODE" hgc_orthomode)
(setvar "AUTOSNAP" hgc_autosnap)
(setvar "APERTURE" hgc_aperture)
(setvar "DIMZIN" hgc_dimzin)
(setvar "EXPERT" hgc_expert)
(command-s ".UNDO" "END") ;05-16-16 Changed to command-s
(setvar "CMDECHO" hgc_cmdecho)
(prin1)
)