大家好,
又是我!
我对此感到好奇和鼓舞:
有没有人有过类似的经验?
我的意思是:
[执行此操作]或选择[option1/option2/option3…]在做这件事的时候。
以下是我对getstring和getkword的尝试:
- ;(Do this) or (do that)
- ;Type string or choose keyword:
- ;Similar: getdist or getreal
- (defun c:test ( / ans )
- (setq ans (getstring t "\nType a string or [KWORD] : "))
- (cond
- ( (= ans "KWORD") ( (initget 1 "KW1 KW2 KW3") (setq ans (getkword "\nChoose keyword [KW1/KW2/KW3] : ")) (princ (strcat "\nFinal answer is " ans " ")) )
- ; (cond
- ; ( (= ans "KW1" ) (princ "\nFinal answer is keyword1 ") )
- ; ( (= ans "KW2" ) (princ "\nFinal answer is keyword2 ") )
- ; ( (= ans "KW3" ) (princ "\nFinal answer is keyword3 ") )
- ; (t (princ (strcat "\nFinal answer is " ans " ")) )
- ; );cond
- ) ; = ans "KWORD"
- (t (princ (strcat "\nFinal answer is " ans " "))
- ); t
- );cond
- ; (princ (strcat "\nFinal answer is " ans " "))
- (princ)
- );defun
- (princ)
然而,我遇到的问题是:
- Choose keyword [KW1/KW2/KW3] : KW1
- Invalid option keyword.
我不理解为什么指定的选项无效,因为它包含在initget函数中。
无论如何,我喜欢这种方法,因为对于getdist和getreal函数,值可以用图形和分析方式表示(无需额外提示选择图形或分析方法)。 |