flowerrobot Posted January 16, 2009 Posted January 16, 2009 Good morning. Todays question is about intiget & getkwords I have a Promt, that either wants a keyword or a distance (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 (initget 7 "hi") (setq hello ((or (getkword) (getdist)) "\HOW far")) Quote
Lee Mac Posted January 16, 2009 Posted January 16, 2009 How about this? (defun c:test (/ hello) (or (and (not (initget 6)) (setq hello (getdist "\nHow Far? <key> "))) (and (not (initget 1 "hi")) (setq hello (getkword "\How far? ")))) (alert (vl-princ-to-string hello)) (princ)) Quote
Lee Mac Posted January 16, 2009 Posted January 16, 2009 Obviously you only need this bit: (or (and (not (initget 6)) (setq hello (getdist "\nHow Far? <key> "))) (and (not (initget 1 "hi")) (setq hello (getkword "\How far? ")))) but I thought I'd test it Quote
Lee Mac Posted January 16, 2009 Posted January 16, 2009 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. Quote
CarlB Posted January 16, 2009 Posted January 16, 2009 Since "getdist" honors keywords, you should be able to use: (initget 7 "hi") (setq hello (getdist "\HOW far ")) Quote
flowerrobot Posted January 16, 2009 Author Posted January 16, 2009 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. Quote
flowerrobot Posted January 16, 2009 Author Posted January 16, 2009 tell me my smart friends why does this not work? well it works, but dosnt honour the kword (initget 7 "100 150 200 250 310") (setq sectype (getint "\nWHAT SIZE IS IT? 100/150/200/250/310 : "))] Quote
CarlB Posted January 16, 2009 Posted January 16, 2009 "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". Quote
Lee Mac Posted January 16, 2009 Posted January 16, 2009 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.