Jump to content

initget & getkword w/ default value - question?


ODEY

Recommended Posts

hello guys! need a little help.

i wonder if it is possible to have a "default values" if my inputs are controlled by initget & getkword. does anybody have an idea?

 

here is the sample code w/c is not working:

(defun c:dvtest ()
 
 (or dvdia (setq dvdia "8")); set global variable

 (initget "8 10 12 16 20 25 32 40");valid inputs
 (if (/= "" (setq strdia(getkword(strcat "\nEnter Bar Diameter <" dvdia "> "))))
   (setq dvdia strdia)
 )
 (princ "\nThe Bar diameter is ")
 (princ dvdia)
 (princ)
)

 

and here is the sample code where inputs are not restricted by initget & getkword but is working:

(defun c:dvtest2 ()
 
 (or dvdia (setq dvdia "8")); set global variables

 (if (/= "" (setq strdia(getstring(strcat "\nEnter Bar Diameter <" dvdia "> "))))
   (setq dvdia strdia)
 )
 (princ "\nThe Bar diameter is ")
 (princ dvdia)
 (princ)
)

Link to comment
Share on other sites

i see. that was a quick response.

got follow up question, in your sample code, can we include default value (prevoius selection). try to play w/ MLEADER command and you'll see what i mean.

tnx.

Link to comment
Share on other sites

Just check the post #7 from above suggested thread. I have removed the code example from my post after found that thread (is more appropriate for your issue).

 

Regards,

Link to comment
Share on other sites

perfect! that was exactly what i'm looking for.

next time, i'll try to search first if such thread is already existing before i post a question here.

thanks a lot!

Link to comment
Share on other sites

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