乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 77|回复: 6

[编程交流] 需要的值,输入忽略

[复制链接]

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 10:59:56 | 显示全部楼层 |阅读模式
你好
假设用户按enter键而不是给定值。我怎么能让程序继续运行并只返回用户给定的值呢。
例如:
 
如何仅获取给定值并正常运行程序。。?
 
非常感谢。
 
塔瓦特
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 11:13:08 | 显示全部楼层
检查INITGET语句,将允许约束用户答案并将该答案与nil进行比较-这是在命中而不是输入时返回的。
 
当做
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 11:21:52 | 显示全部楼层
谢谢msasu。
所有(initget)值都不允许为,如下所示,
  1. Establishes limitations on the user responses allowed by the next get- function
  2. (initget 1) null input not allowed ("null input" means 'Enter' by itself)
  3. (initget 2) 0 input not allowed
  4. (initget 3) null input and 0 input not allowed (3 = 1 + 2)
  5. (initget 4) negative values not allowed
  6. (initget 5) null input and negative values not allowed (5 = 1 + 4)
  7. (initget 6) 0 input and negative values not allowed (6 = 2 + 4)
  8. (initget 7) null input, 0 input, and negative values not allowed (7 = 1 + 2 + 4)
  9. (initget  cancels limits check
  10. (initget 16) (not used)
  11. (initget 32) causes get- functions that include a base point to display a rubber band cursor or window that is highlighted rather than solid
  12. (initget 64) Z coordinate not allowed in next getdist function
  13. (initget 128) allows arbitrary input (accepts any "key word")
  14. (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.

 
我觉得有些事情是不允许的。
 
当做
塔瓦特
回复

使用道具 举报

5

主题

194

帖子

193

银币

初来乍到

Rank: 1

铜币
24
发表于 2022-7-6 11:30:39 | 显示全部楼层
也许可以在测试中使用IF语句
 
可能有几种方法可以做到这一点。只是一个样本
 
  1. (if (setq Input (getdist "\nLength of First Peice: " ))(setq pcs1 Input))
  2. (if (setq Input (getdist "\nLength of Second Peice: "))(setq pcs2 Input))
  3. (if (setq Input (getdist "\nLength of Third Peice: " ))(setq pcs3 Input))

 
或者如果您想存储默认值
 
  1. (or pcs1 (setq pcs1 10.0))
  2. (if
  3. (setq Input (getdist (strcat "\nLength of First Peice [" (rtos  pcs1) "] : " )))
  4. (setq pcs1 Input))
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 11:42:54 | 显示全部楼层
非常感谢jammie
 
这两个提议都很棒。。。尤其是第二个,它保存了价值。
 
一再感谢。
 
恕我直言
 
塔瓦特
回复

使用道具 举报

5

主题

194

帖子

193

银币

初来乍到

Rank: 1

铜币
24
发表于 2022-7-6 11:53:38 | 显示全部楼层
欢迎光临!
 
很乐意帮忙
 
当做
 
杰米
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
438
发表于 2022-7-6 12:03:29 | 显示全部楼层
还有两个例子:
 
  1. (setq pcs1 (cond ((getdist "\nLength of First Peice <10.0>: "))
  2.                 (10.0)
  3.           )
  4. )

 
  1. (setq *pcs1* (cond ((getdist (strcat "\nLength of First Peice <"
  2.                                     (rtos (cond (*pcs1*)
  3.                                                 ((setq *pcs1* 10.0))
  4.                                           )
  5.                                     )
  6.                                     ">: "
  7.                             )
  8.                    )
  9.                   )
  10.                   (*pcs1*)
  11.             )
  12. )
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-6 11:22 , Processed in 0.385430 second(s), 66 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表