出错循环
这个出错了两次就要重新执行命令,怎么设置成无限出错循环?(defun c:tt()(setvar "cmdecho"0)
(defun *error*(msg)
(setq txt(getint "\n加工数量<1>:"))
(if(= txt nil)
(setq txt 1))
(xh))
(setq txt(getint "\n加工数量<1>:"))
(if(= txt nil)
(setq txt 1))
(setq s(getreal "\n文字高度:"))
(if (= s nil)
(setq s 3.5)
)
(xh)
)
(defun xh()
(while txt
(setq pt(getpoint "\n文字位置:"))
(command "text" "j" "mc" pt s 0 (strcat "数量:" (itoa txt) "Pcs"))
)
)
你用捕获函数试试
Passes a list of arguments to a specified function and traps any exceptions
(vl-catch-all-apply 'function list)
Arguments
'function
A function. The function argument can be either a symbol identifying a defun, or a lambda expression.
list
A list containing arguments to be passed to the function.
本帖最后由 仲文玉 于 2013-5-8 18:39 编辑
不知道你要什么效果,猜摸着改下,也不知道是不是这个意思?自己加下出错处理(defun c:ttt ()
(setvar "cmdecho" 0)
(setq txt (getint "\n加工数量<1>:"))
(if (= txt nil)(setq txt 1))
(setq s (getreal "\n文字高度:"))
(if (= s nil)(setq s 3.5))
(while (setq pt(getpoint "\n文字位置:"))
(command "text" "j" "mc" pt s 0 (strcat "数量:" (itoa txt) "Pcs"))
(setqtxt (1+ txt))
)
) 英雄无敌 发表于 2013-5-8 16:52 static/image/common/back.gif
你用捕获函数试试
Passes a list of arguments to a specified function and traps any exceptions
怎么捕获?我想在插入文字那里右键可以重新输入加工数量. 仲文玉 发表于 2013-5-8 18:09 static/image/common/back.gif
不知道你要什么效果,猜摸着改下,也不知道是不是这个意思?自己加下出错处理
我想将这个程式改为循环插入加工件数,而且中途可以改加工数量,我加了出错处理目的是按了ESC键后程式跳到出错处理那里重新输入加工数量的,但是只可以运行两次之后就要重新执行命令了 如果无限出错循环,那你还怎么退出啊?
lsp不是别的高级语言,可以有GOTO语句,如果你要点右键再回到输入数量,可以加一个while循环
(while (= 写好文字 nil)
(输入数量)
...
...
(if 写文字
(setq 写好文字 t)
(setq 写好文字 nil)
)
)
具体自己慢慢去体会,只是一个思路
页:
[1]