条件执行子程序,该如何写?谢谢!
(defun C:DE(/ )(tt);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;子程序1
(setvar "osmode" 0)
(initget "M D")
(setq a0 (getkword "\n[面 M/底 D]<M>:"))
(if (= M a0)
(progn (get_ent1));;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;子程序2
(progn (get_ent2));;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;子程序3
)
(prin1)
)
猜是
(= M a0)==> (= "M" a0)
getkword的返回值是字串。 lisp语言都叫函数,自定义函数和主函数一样定义,(defun tt(/ a b c d)
(setq a 19 b 78 c 65)
(setq d (- a b c))
(princ d)
)
(defun C:DE(/ )
(setvar "osmode" 0)
(tt)
(initget "M D")
(setq a0 (getkword "\n[面 M/底 D]<M>:"))
(if (= a0 nil )(setq a0 "M"))
(if (= a0 "M")
(progn (get_ent1));;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;子程序2
(progn (get_ent2));;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;子程序3
)
(prin1)
)
(defun tt ( );
(prinC"子程序1" )
)
(defun get_ent1 ( )
(prinC"子程序2" )
)
(defun get_ent2 ( )
(prinC"子程序3" )
)
页:
[1]