You put in error handler old sys variables values and in main body of routine usually at start, you change sys vars to what you need... At the end, just call error handler and sys vars should be restored; this also means that if routine cancels, breaks, or similar - error handler will restore them...
(defun c:foo ( / *error* cmd osm ... )
(defun *error* ( m )
(if cmd
(setvar 'cmdecho cmd)
)
(if osm
(setvar 'osmode osm)
)
(if m
(prompt m)
)
(princ)
)
;;; MAIN ;;;
(setq osm (getvar 'osmode))
(setvar 'osmode 0)
(setq cmd (getvar 'cmdecho))
(setvar 'cmdecho 0)
...
do stuff...
...
(*error* nil) ; clean exit - quiet - last statement in error handler is (princ)
)
HTH., M.R.
if use vl-cmdf have this promble,i usually use command ,so not this promble.
use command if has error ,it is end lisp.but vl-cmdf not end lisp.
thanks so much.
{(setq e_lst (mapcar (function (lambda (n) (list 'setvar n (getvar n)))) '("cmdecho" "osmode")))
(defun *error* (msg)
(mapcar 'eval e_lst)
(princ "")
)
}=enter code first remember now system variables if error recovery these system variables
(setq osm (getvar "osmode"))
(setq ocmd (getvar "cmdecho"))
.................................
.................................
(setvar "osmode" osm )
(setvar "cmdecho" ocmd)
with your code same function?