NextPrevUpTopContentsIndex

10.2.2 Prompting for numbers

The CAPI also provides a number of more specific dialogs that allow you to enter other types of data. For example, to enter an integer, use the function prompt-for-integer . Only integers are accepted as valid input for this function.

(prompt-for-integer
 "Enter an integer:")

There are a number of extra options which allow you to specify more strictly which integers are acceptable. Firstly, there are two arguments :min and :max which specify the minimum and maximum acceptable integers.

(prompt-for-integer
 "Enter an integer:"
 :min 10 :max 20)

If this does not provide enough flexibility you can specify a function that validates the result with the keyword argument :ok-check . This function is passed the current value and must return non- nil if it is a valid result.

(prompt-for-integer
 "Enter an integer:"
 :ok-check 'oddp)

Try also the function prompt-for-number .


LispWorks CAPI User Guide (Windows version) - 14 Jun 2006

NextPrevUpTopContentsIndex