需要的值,输入忽略
你好假设用户按enter键而不是给定值。我怎么能让程序继续运行并只返回用户给定的值呢。
例如:
如何仅获取给定值并正常运行程序。。?
非常感谢。
塔瓦特 检查INITGET语句,将允许约束用户答案并将该答案与nil进行比较-这是在命中而不是输入时返回的。
当做 谢谢msasu。
所有(initget)值都不允许为,如下所示,
Establishes limitations on the user responses allowed by the next get- function
(initget 1) null input not allowed ("null input" means 'Enter' by itself)
(initget 2) 0 input not allowed
(initget 3) null input and 0 input not allowed (3 = 1 + 2)
(initget 4) negative values not allowed
(initget 5) null input and negative values not allowed (5 = 1 + 4)
(initget 6) 0 input and negative values not allowed (6 = 2 + 4)
(initget 7) null input, 0 input, and negative values not allowed (7 = 1 + 2 + 4)
(initgetcancels limits check
(initget 16) (not used)
(initget 32) causes get- functions that include a base point to display a rubber band cursor or window that is highlighted rather than solid
(initget 64) Z coordinate not allowed in next getdist function
(initget 128) allows arbitrary input (accepts any "key word")
(initget "A B C") allows the user to enter "A" "B" "C" "a" "b" or "c" in response to the next get- function (in addition, of course, to the possibility of entering an integer if the next get- function is getint, a real if it is getreal, etc.) Subsequent programming must be set up to handle these strings.
我觉得有些事情是不允许的。
当做
塔瓦特 也许可以在测试中使用IF语句
可能有几种方法可以做到这一点。只是一个样本
(if (setq Input (getdist "\nLength of First Peice: " ))(setq pcs1 Input))
(if (setq Input (getdist "\nLength of Second Peice: "))(setq pcs2 Input))
(if (setq Input (getdist "\nLength of Third Peice: " ))(setq pcs3 Input))
或者如果您想存储默认值
(or pcs1 (setq pcs1 10.0))
(if
(setq Input (getdist (strcat "\nLength of First Peice [" (rtospcs1) "] : " )))
(setq pcs1 Input)) 非常感谢jammie
这两个提议都很棒。。。尤其是第二个,它保存了价值。
一再感谢。
恕我直言
塔瓦特 欢迎光临!
很乐意帮忙
当做
杰米 还有两个例子:
(setq pcs1 (cond ((getdist "\nLength of First Peice <10.0>: "))
(10.0)
)
)
(setq *pcs1* (cond ((getdist (strcat "\nLength of First Peice <"
(rtos (cond (*pcs1*)
((setq *pcs1* 10.0))
)
)
">: "
)
)
)
(*pcs1*)
)
)
页:
[1]