LispWorks CAPI User Guide > 10 Prompting for Input > 10.2 Prompting for values


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.

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

 "Enter an integer in the inclusive range [10,20]:"
 :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.

 "Enter an odd integer:"
 :ok-check 'oddp)

Try also the function prompt-for-number .

LispWorks CAPI User Guide (Macintosh version) - 22 Dec 2009