How can I read ESC key in middle of a lisp function - eg with grread to cancel a lisp command?
For example ESC is a user option if function is going wrong or one just wants to stop it before completed?
Re: Using grread on ESCAPE key to cancel a lisp function
#2Hi,
Try to run the simple lisp:
Try to run the simple lisp:
Code: Select all
(defun c:test()
(while ; stay in loop until one of the COND statements return nil
(progn
(setq input (vl-catch-all-apply 'grread (list T (+ 1 2 0))))
(cond
((vl-catch-all-error-p input)
(princ "\nPressed escape ")
nil ; exit
)
((= 5 (car input)) ; pointing device
(cond
((and LastPT (< (distance (cadr input) LastPT) 0.01))) ; no update if same point
((setq ent (nentselp (setq LastPT (cadr input))))
(setq objName (cdr (assoc 0 (entget (car ent)))))
(princ (strcat "\nObject name: " objName))
)
)
t ; stay in loop
)
)
)
) ; while
(princ)
)