关于局部变量的理解
1(setq i 1)2(Phasei )
(defun Phase ( / i)
(if (= (rem i 3) 1) (setq Circuit_Phase (strcat (itoa i ) "a")))
(if (= (rem i 3) 2) (setq Circuit_Phase (strcat (itoa i ) "b")))
(if (= (rem i 3) 0) (setq Circuit_Phase (strcat (itoa i ) "c")))
(princ Circuit_Phase)
(setq i (1+ i))
)
先给变量赋值(setq i 1) ,然后执行多次 (Phasei )应该怎么写变量能让依次(princ Circuit_Phase)结果为1a, 2b,3c
这里搞不懂( / i ) 貌似每次都执行是1a
谢谢解答
本帖最后由 Gu_xl 于 2015-3-2 14:16 编辑
全局变量不要和局部变量重名!
1(setq i 1)
2(Phase)
(defun Phase ( )
(if (= (rem i 3) 1) (setq Circuit_Phase (strcat (itoa i ) "a")))
(if (= (rem i 3) 2) (setq Circuit_Phase (strcat (itoa i ) "b")))
(if (= (rem i 3) 0) (setq Circuit_Phase (strcat (itoa i ) "c")))
(princ Circuit_Phase)
(setq i (1+ i))
) 十分感谢,感觉懵懂了
页:
[1]