The optional string argument specifies a list of keywords recognized by the next user-input function call.
The initget function allows keyword abbreviations to be recognized in addition to the full keywords. The user-input function returns a predefined keyword if the input from the user matches the spelling of a keyword (not case sensitive), or if the user enters the abbreviation of a keyword. There are two methods for abbreviating keywords; both are discussed in the initget topic in the AutoLISP Reference.
The following user-defined function shows a call to getreal, preceded by a call to initget, that specifies two keywords. The application checks for these keywords and sets the input value accordingly.
(defun C:GETNUM (/ num)
(initget 1 "Pi Two-pi")
(setq num (getreal "Pi/Two-pi/<number>: "))
(cond
((eq num "Pi") pi)
((eq num "Two-pi") (* 2.0 pi))
(T num)
)
)
This initget call inhibits null input (bits = 1) and establishes a list of two keywords, "Pi" and "Two-pi". The getreal function is then used to obtain a real number, issuing the following prompt:
Pi/Two-pi/<number>:
The result is placed in local symbol num. If the user enters a number, that number is returned by C:GETNUM. However, if the user enters the keyword Pi (or simply P), getreal returns the keyword Pi. The cond function detects this and returns the value of p in this case. The Two-pi keyword is handled similarly.