I think you are correct. However what I would like to do is have one universal error function for all routines that would override any existing error function,
like what one would do with the following ex: (setq S::Startup (append S::Startup ARCH::STARUP))
It would be neat if you could append, redefine or what ever and have the global-universar error function work for everthing. As part of this error funtion it would reset
all vars.
Here is what I use for each routine, error trapped within each routine.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Undo Mark Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:UBEG ()
(setvar "CMDECHO" 0)
(setq UNDO_BEGIN T)
(command "UNDO" "BEGIN")
(setvar "CMDECHO" 1)
(princ))
(defun ARCH:UEND ()
(setvar "CMDECHO" 0)
(setq UNDO_BEGIN ())
(command "UNDO" "END")
(setvar "CMDECHO" 1)
(princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Error Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:ERROR (Msg)
(setvar "cmdecho" 0)
;;(command "_ucs" "");dont use
(setvar "cmdecho" 1)
(if (and Msg (not (eq Msg "quit / exit abort")))
;;(princ Msg)
(princ "\n\n*** ///////// Program CANCELLED ///////// ***\n"))
(ARCH:F_R-VAR)
(princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Error Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:ERROR (Msg)
(setvar "cmdecho" 0)
;;(command "_ucs" "");dont use
(setvar "cmdecho" 1)
(if (and Msg (not (eq Msg "quit / exit abort")))
;;(princ Msg)
(princ "\n\n*** ///////// Program CANCELLED ///////// ***\n"))
(ARCH:F_R-VAR)
(princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Clean Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Juerg Menzi
;;;MENZI ENGINEERING GmbH, Switzerland
;;;http://www.menziengineering.ch
(defun ARCH:F_CLEAN (Lst)
(or Me:Aco (setq Me:Aco (vlax-get-acad-object)))
(or Me:Acd (setq Me:Acd (vla-get-ActiveDocument Me:Aco)))
(vla-StartUndoMark Me:Acd)
(setq Me:Oer *Error*
*Error* ARCH:ERROR)
(mapcar '(lambda (l)
(if (not (assoc l Me:Var))
(setq Me:Var (append Me:Var (list (cons l (getvar l)))))))
Lst)
(princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; F_S-VAR Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:F_S-VAR ()
(ARCH:F_CLEAN
'("APERTURE" "ATTDIA" "ATTREQ" "BLIPMODE" "CECOLOR" "CLAYER" "CELTYPE" "CMDECHO"
"DIMSCALE" "DRAGMODE" "EXPERT" "FILEDIA" "FILLETRAD" "GRIDMODE" "HIGHLIGHT" "LUNITS"
"MENUECHO" "MIRRTEXT" "OFFSETDIST" "ORTHOMODE" "OSMODE" "PICKBOX" "PLINEWID" "REGENMODE"
"SNAPMODE" "SNAPUNIT" "SNAPBASE" "SNAPANG" "SNAPSTYL" "TEXTEVAL" "TEXTSTYLE")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; F_R-VAR Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Juerg Menzi
;;;MENZI ENGINEERING GmbH, Switzerland
;;;http://www.menziengineering.ch
(defun ARCH:F_R-VAR ()
(if Me:Var
(mapcar '(lambda (l) (setvar (car l) (cdr l))) Me:Var))
(setq *Error* Me:Oer
Me:Oer nil
Me:Var nil)
(vla-EndUndoMark Me:Acd)
(princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;; Check Global Variables Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;10/13/99 Bill Zondlo
;;;use this program to clean up your custom autolisp programs.
;;;quickly finds user global variables/functions defined during use of custom programs,
;;;so you can add them to your local variables list without searching each line of program.
;;;It displays a list of new variables set during the drawing session.
;;;(setq ARCH#CHKV (atoms-family 1)) ;add to s::startup to make list
(defun ARCH:ChkGlobalVals (/ ltr ltt)
;;;after custom program is run, run this program.
(setq ltt (atoms-family 1))
;;;to get list of newly defined variables/functions.
(princ (strcat "\nARCH#CHKV > "
(rtos (length ARCH#CHKV) 2 0)
" - ltt > "
(rtos (length ltt) 2 0))) ;prints length of each list.
(foreach
n ltt ;compares each item in new list.
(if (not (member n ARCH#CHKV))
;of newly defined variables/functions since start of drawing.
(setq ltr (append ltr (list n))) ;makes list of new items.
) ;end if
(ARCH:WORKING)) ;end foreach
(if (not (null ltr)) ;if new items.
(progn (textscr) ;flips to text screen.
(foreach m ltr (princ (strcat "\n " m))) ;prints new items to screen.
) ;end progn
) ;end if
(princ)) ;end defun
Gary (in the dark)