乐筑天下

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

[编程交流] Initget & getkword

[复制链接]

41

主题

301

帖子

265

银币

后起之秀

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

铜币
209
发表于 2022-7-6 15:18:17 | 显示全部楼层 |阅读模式
Good morning.
Todays question is about intiget & getkwords
I have a Promt, that either wants a keyword or a distance
 
  1.   (setq    mp1 (strcase (getstring "\nENTER WIDTH PLATE, or key for options : ")))(terpri)
This is how it is currently set
but as im now just about done debuging it, and this one is buging me, as i want all prompts to be idiot proof. so that i can only select defined letter , or any distance. i only have the knowledge to do either.
this is what i want to happen,(you get the point
  1. (initget 7 "hi")(setq hello ((or (getkword) (getdist)) "\HOW far"))
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:32:20 | 显示全部楼层
How about this?
 
  1. (defun c:test (/ hello)   (or    (and (not (initget 6)) (setq hello (getdist "\nHow Far?   ")))          (and (not (initget 1 "hi")) (setq hello (getkword "\How far? "))))   (alert (vl-princ-to-string hello))   (princ))
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:37:47 | 显示全部楼层
Obviously you only need this bit:
 
  1.    (or    (and (not (initget 6)) (setq hello (getdist "\nHow Far?   ")))          (and (not (initget 1 "hi")) (setq hello (getkword "\How far? "))))
but I thought I'd test it
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:47:14 | 显示全部楼层
But I'm sure there is a better way to accomplish this - I don't like the user having to press enter to get to the keyword request.
回复

使用道具 举报

0

主题

269

帖子

279

银币

限制会员

铜币
-4
发表于 2022-7-6 15:55:14 | 显示全部楼层
Since "getdist" honors keywords, you should be able to use:
 
  1. (initget 7 "hi")(setq hello (getdist "\HOW far "))
回复

使用道具 举报

41

主题

301

帖子

265

银币

后起之秀

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

铜币
209
发表于 2022-7-6 16:00:50 | 显示全部楼层
o.0 it does too. I must of screw up last night then when i tryed it. (it was close to my bed time)
 
Thank you for the help with my ignorance.
回复

使用道具 举报

41

主题

301

帖子

265

银币

后起之秀

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

铜币
209
发表于 2022-7-6 16:09:33 | 显示全部楼层
tell me my smart friends
why does this not work?
well it works, but dosnt honour the kword
  1. (initget 7 "100 150 200 250 310")(setq sectype (getint "\nWHAT SIZE IS IT? 100/150/200/250/310 : "))]
回复

使用道具 举报

0

主题

269

帖子

279

银币

限制会员

铜币
-4
发表于 2022-7-6 16:14:30 | 显示全部楼层
"getint" also honors keywords.  but your use of it would allow any positive integer t be input, as well as the keywords which you have as certain text which happen to be numbers.  If you want to just allow those numbers to be input then i'd say use "getkword" not "getint".
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 16:23:15 | 显示全部楼层
I must admit, I did not realise, GetInt and GetDist and maybe others honoured keywords -
 
But as Carl rightfully says, in the above example, the list of integers within the initget phrase become keywords, but the use of getint instead of getkword means that every integer is allowed as well as the keywords inside the initget.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 20:54 , Processed in 0.354000 second(s), 70 queries .

© 2020-2025 乐筑天下

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