Hello to all,
for many years I use the following code for error handling.
(defun c:test (/ var msgg)
;*************************************
(setq var (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setq old-error *error*)
(defun *error* (msg)
(setq msgg (strcat "Error!!: " msg))
(princ msgg)
(setq *error* old-error)
(command "_.undo" "_end" "_u")
(exit)
)
(command "_.undo" "_be")
(setq var_OSMODE (getvar "OSMODE"))
(setvar "OSMODE" 1)
;*************************************
(while (= 1 1)
(command "_.line" "0,0,0" "10,10,0" "")
)
;*************************************
(setvar "OSMODE" var_OSMODE)
(setq *error* old-error)
(command "_.undo" "_end")
(setvar "cmdecho" var)
(princ)
)
This code should restore the situation of the original design before the work lisp.
It has worked for 15 years, or at least I was convinced of this; today does not work
Today, in AutoCAD 2011, if I press ESC, the while loop is interrupted, and design are all generated before pressing the ESC key.
Instead I wish that these lines were automatically removed.
Can you help me understand this?
Also in AutoCAD2016 it goes in error because of the (command).
AutoCAD 2016 wants the (command-s) ...
What is the difference between (command) and (command-s) ??