You can also, if you like, have it offer your prior choice as default on subsequent use, so you can use Enter/space to accept that, instead of typing/picking it again, similar to the way many AutoCAD commands work. And you can have an initial default to offer, or not. This is a way if you want an initial default offered on first use:
(defun c:TestYourPedit ()
(initget "Open Join Width")
(setq opt ; must be a global [not localized] variable to remain available on subsequent use
(cond
( (getkword ; <-- returns nil on Enter
(strcat
"PEDIT Enter an option [Open/Join/Width] <"
(cond (opt) ("Join")); <-- prior choice as default if present, otherwise Join
">: "
); strcat
); getkword
); end User-input condition
(opt); <-- prior choice on Enter, if present
("Join"); <-- initial default on Enter at first use
); cond
); setq
.... whatever ....
); defun
This is a way if you don't want an initial default offered, but want to require the User to specify the first time:
(defun c:TestYourPedit ()
(initget (if opt 0 1) "Open Join Width"); <-- allows Enter only if there's a prior choice
(setq opt
(cond
( (getkword ; <-- returns nil on Enter [only when permitted]
(strcat
"PEDIT Enter an option [Open/Join/Width]"
(if opt (strcat " <" opt ">") ""); <-- offers prior choice default only if present
": "
); strcat
); getkword
); end User-input condition
(opt); <-- prior choice on Enter when permitted
); cond
); setq
.... whatever ....
); defun
Kent Cooper, AIA