明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1612|回复: 8

请教各位高手:加急!!!!!

[复制链接]
发表于 2005-3-9 15:53 | 显示全部楼层 |阅读模式
各位高手:
大家好!我现在遇到了一个关于lisp测试的问题。请大家帮忙指教一下。
怎么能让下面的一个个小程序用一个总的函数(母程序)来调用?就是不用一个个的在命令行去输入他,自己就可以一直执行下去。
我这两天就要用,去面试工作,请大家一定帮帮忙!谢谢了!!!!!
(defun c:lc1()
(princ "\n") (princ "坐标测试")
(princ "\n")
(command "line" (list 0 0) (list 50 50) "")
(command "erase" (entlast) "")
(princ "\n") (princ "测试正常")
(princ)
)
;
(defun c:lc2()
(princ "\n") (princ "坐标测试")
(princ "\n")
(command "line" (0 0) (50 50) "")
(command "erase" (entlast) "")
(princ "\n") (princ "line指令指定点坐标输入有误!")
(princ "\n") (princ "请输入正确点坐标")
(princ)
)
; 错误: 函数错误: 0
(defun c:lc3()
(princ "\n") (princ "坐标测试")
(princ "\n")
(command "line" (0,0) (50,50) "")
(command "erase" (entlast) "")
(princ "\n") (princ "line指令对(0,0)格式没有定义!")
(princ "\n") (princ "请输入正确点坐标格式")
(princ)
)
; 错误: no function definition: 0,0
发表于 2005-3-9 16:03 | 显示全部楼层
那就把这三个子函数都放在一个 c:xx 函数里!
发表于 2005-3-9 16:04 | 显示全部楼层
你想要问什么? 注:第二、第三个程序的第一个command后面的内容都不会执行了,后面这些代码完全是多余的,改成如下,不知是否满足你的意思: (defun c:lc2( / errlc2 errtmp)
(defun errlc2(msg)
(command)
(princ "\n") (princ "line指令指定点坐标输入有误!")
(princ "\n") (princ "请输入正确点坐标")
(setq *error* errtmp)
(princ)
)
(setq errtmp *error*)
(setq *error* errlc2)
(princ "\n") (princ "坐标测试")
(princ "\n")
(command "line" (0 0) (50 50) "")
)
(defun c:lc3( / errlc3 errtmp)
(defun errlc3(msg)
(command)
(princ "\n") (princ "line指令对(0,0)格式没有定义!")
(princ "\n") (princ "请输入正确点坐标格式")
(setq *error* errtmp)
(princ)
)
(setq errtmp *error*)
(setq *error* errlc3)
(princ "\n") (princ "坐标测试")
(princ "\n")
(command "line" (0,0) (50,50) "")
)
 楼主| 发表于 2005-3-10 14:58 | 显示全部楼层
meflying,honboo : 你们好!你们说的都很好.meflying给我改的也很好.但是我还是不会怎么把他们连在一起.请帮我写一下,好吗? 谢谢!!!!!!!!!!
发表于 2005-3-10 15:09 | 显示全部楼层
如果要连接三个程序很简单,在三个程序都不错的情况下: (defun c:lc1() 改成 (defun lc1() (defun c:lc2() 改成 (defun lc2() (defun c:lc3() 改成 (defun lc3() 然后在程序中加上: (defun c:lc() (lc1) (lc2) (lc3) )
发表于 2005-3-10 17:19 | 显示全部楼层
看看这个吧,同学之间都不互相讨论一下啊。。。 http://bbs.mjtd.com/forum.php?mod=viewthread&tid=33405
发表于 2005-3-11 09:05 | 显示全部楼层
peng197806 函数都正确才可以向下走,错误就不能走了,函数将自动退出,不好意思! 还是感谢你! meflying大哥,我们一直在交流!
 楼主| 发表于 2005-3-29 15:25 | 显示全部楼层
meflying大哥: 谢谢你对我的帮助,我的考试已经全部通过了.谢谢你!
发表于 2005-3-29 17:05 | 显示全部楼层
恭喜
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-19 06:31 , Processed in 0.191447 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表