getkword
 
 
 

Pauses for user input of a keyword, and returns that keyword

(getkword [msg]) 

Valid keywords are set prior to the getkword call with the initget function. The user cannot enter another AutoLISP expression as the response to a getkword request.

Arguments

msg

A string to be displayed to prompt the user; if omitted, getkword does not display a prompting message.

Return Values

A string representing the keyword entered by the user; otherwise nil, if the user presses ENTER without typing a keyword. The function also returns nil if it was not preceded by a call to initget to establish one or more keywords.

If the user enters a value that is not a valid keyword, getkword displays a warning message and prompts the user to try again.

Examples

The following example shows an initial call to initget that sets up a list of keywords (Yes and No) and disallows null input (bits value equal to 1) to the getkword call that follows:

Command: (initget 1 "Yes No")

nil

Command: (setq x (getkword "Are you sure? (Yes or No) "))

Are you sure? (Yes or No) yes

"Yes"

The following sequence illustrates what happens if the user enters invalid data in response to getkword:

Command: (initget 1 "Yes No")

nil

Command: (setq x (getkword "Are you sure? (Yes or No) "))

Are you sure? (Yes or No) Maybe

Invalid option keyword.

Are you sure? (Yes or No) yes

"Yes"

The user's response was not one of the keywords defined by the preceding initget, so getkword issued an error message and then prompted the user again with the string supplied in the msg argument.

See Also