This is the way I approach it, I borrowed this code from stig
some time back.
You will notice at the end of the routine *error* ""
this flags the normal exit and the error routine is used to reset
variables changed during start up.
Also note "console break" "Function cancelled" "quit / exit abort"
any of those messages are caused by the user pressing ESCAPE.
(defun c:mainroutine (/ *error* useror useros usercmd)
;; error function & Routine Exit
(defun *error* (msg)
(if
(not
(member
msg
'("console break" "Function cancelled" "quit / exit abort" "")
)
)
(princ (strcat "\nError: " msg))
) ; endif
;;reset all variables here
(setvar "orthomode" useror)
(setvar "osmode" useros)
(setvar "CMDECHO" usercmd)
) ;end error function
;;; =================================================================
;;; Main Routine
;;; =================================================================
(setq usercmd (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setq useros (getvar "osmode"))
(setq useror "orthomode")
;; ****************************************
;; Your code goes here
;; ****************************************
;; End of main routine and exit
(*error* "") ; call error routine to reset vars
(princ) ; exit quietly
) ; end defun