trueman 发表于 2006-1-3 19:16:00

如何进行错误处理?

<P>&nbsp;&nbsp;&nbsp; 为了操作时返回方便,我通常在程序中加入</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; (command "undo" "be")</P>
<P>&nbsp;&nbsp; 和</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; (command "undo"&nbsp; "e").但如果程序在运行过程中中断,就要特别运行一下undo命令undo命令才能用.</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 请教各路英雄如何进行这种类型的错误处理</P>

HuaiYu 发表于 2006-1-3 22:05:00

大不了自定义*error*函数

trueman 发表于 2006-1-4 12:13:00

    能不能来个例子啊,谢谢了

bobby 发表于 2006-1-5 18:25:00

<P>看看下面的程序是否是你想要的。</P>
<P>(defun c:mal ()<BR>&nbsp; (defun BZERR (st)<BR>&nbsp;&nbsp;&nbsp; (command "undo" "")<BR>&nbsp;&nbsp;&nbsp; (setq *error* olderr)<BR>&nbsp;&nbsp;&nbsp; (princ)<BR>&nbsp; )<BR>&nbsp; (setq&nbsp;olderr&nbsp;*error*<BR>&nbsp;*error*&nbsp;BZERR<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oldcmd (getvar "cmdecho")<BR>&nbsp; )<BR>&nbsp; (setvar "cmdecho" 0)<BR>&nbsp; (command "undo" "be")<BR>&nbsp; (while (and (setq pt1 (getpoint "\nFirst point:"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq pt2 (getpoint pt1 "\nSecond point:"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<BR>&nbsp; (command "line" pt1 pt2 "")<BR>&nbsp; )<BR>&nbsp; (command "undo"&nbsp; "e")<BR>&nbsp; (setq *error* olderr)<BR>&nbsp; (setvar "cmdecho" oldcmd)<BR>&nbsp; (princ)<BR>)</P>

trueman 发表于 2006-1-6 08:52:00

   楼上的还是不错,但我希望是按ESC键后要自动运行的程序,而不需要专门重新输入命令才能恢复系统变量

bobby 发表于 2006-1-6 12:27:00

<P>将你需要恢复的系统变量加到错误处理函数中就好了。</P>
页: [1]
查看完整版本: 如何进行错误处理?