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 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.
(prompt-for-integer
"Enter an odd integer:"
:ok-check 'oddp)
Try also the function
prompt-for-number
.
CAPI User Guide (Unix version) - 30 Aug 2011