(defun my-func ( a1 a2 / a3 )
(vn-errbegin) ;---------- start error handling
(vn-push-sysvars '( ;---------- set sysvars and save old values
("CMDECHO" 0) )) ;---------- to be restored automatically
(command "._undo" "_g")
(vn-errpush '( ;---------- push new action into error handler
(command "._undo" "_e") ;---------- to be done automatically on error
(princ "\n Use Undo Group to go back!") ;--- as well as on exit from the
)) ;--- function via (vn-errend) call
(vn-push-sysvars '(
("DIMZIN" 0)
("CLAYER" )
("AUNITS" 3)
))
(setq a3 (/ a1 a2))
(vn-errend) ;---------- stop error handling and perform all
a3 ;---------- the actions in reverse order and
) ;---------- restore all the saved system variables