Jump to content

Recommended Posts

Posted

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"))

Posted

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))

Posted

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 :P

Posted

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.

Posted

Since "getdist" honors keywords, you should be able to use:

 

(initget 7 "hi")
(setq hello (getdist "\HOW far "))

Posted

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.

Posted

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 : "))]

Posted

"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".

Posted

I must admit, I did not realise, GetInt and GetDist and maybe others honoured keywords - :oops:

 

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...