(DEFUN M1 (C / A B W X)
(setq a (getreal "A=")
b (getreal "B=")
w (+ A B C)
X (* a b C)
)
(princ (strcat "W=" (rtos W)))
(PRINC "\n")
(princ (strcat "X=" (rtos x)))
(princ)
)
;;_$ (M1 3)
不是很清楚想要什么,如果是获取W 可用下面这个
(DEFUN M1 (C / A B W X)
(setq a (getreal "A=")
b (getreal "B=")
w (+ A B C)
X (* a b C)
)
我绝对新手,您那种C:M1(x)我也不知道可以不可以,请其他大侠帮忙解析下;下面这几种我用过,第四种尽量别用,第一种、第三种或许就是您说的那种直接调用
;;;1.调用命令
(defun c:ba (/ a b c)
(setq a (getint)
b (getint)
)
(setq c (+ a b))
c;;供调用
)
(defun c:b1 (/ d)
(setq d (c:ba));;调用(c:ba)
)
;;;b1命令调用了ba命令
;;;;;____________________
;;2. 调用函数******
(defun ba ( a / b c);; a 为外部变量
(setq ;;a (getint)
b (getint)
)
(setq c (+ a b))
c;;供调用
)
(defun c:b2 (/ z d )
(setq z 9)
(setq d (ba z ));;调用ba函数;调用此函数时Z也参与运算
)
;;;;;____________________
;;3. 调用函数******
(defun ba ( / a b c);;
(setq a (getint)
b (getint)
)
(setq c (+ a b))
c;;供调用
)
(defun c:b3 (/ d )
;(setq z 9)
(setq d (ba ));;调用ba函数;调用此函数时Z也参与运算
)
;;;;;____________________
;;4. 调用函数******
(defun ba ( a / b c);; a 为外部变量
(setq ;;a (getint)
b (getint)
)
(setq c (+ a b))
c;;供调用
)
(setq ss 3)
(defun c:b4 ( / d );;SS为全局变量
(setq d (ba ss ));;调用ba函数,ss也参与了运算
)