All Manuals > CAPI User Guide and Reference Manual > 21 CAPI Reference Entries

NextPrevUpTopContentsIndex

prompt-for-integer

Function
Summary

Prompts the user for an integer.

Package

capi

Signature

prompt-for-integer message &key min max initial-value ok-check pane-args popup-args continuation => result, successp

Arguments

message

A string.

min

An integer or nil.

max

An integer or nil.

initial-value

An integer or nil.

ok-check

A function or nil.

pane-args

Arguments to pass to the pane.

popup-args

Arguments to pass to the confirmer.

continuation

A function or nil.

Description

The function prompt-for-integer pops up a text-input-pane and prompts the user for an integer, which is returned in result.

When min or max are specified the allowable result is constrained accordingly.

initial-value determines the initial value displayed in the dialog. initial-value defaults to the value of min , or if min is nil then no initial value is displayed.

Further restrictions can be applied by passing an ok-check function . ok-check should take one argument, the currently entered number, and should return t if it is valid. If ok-check is nil (the default) then there is no further restriction.

If continuation is non-nil, then it must be a function with a lambda list that accepts two arguments. The continuation function is called with the values that would normally be returned by prompt-for-integer. On Cocoa, passing continuation causes the dialog to be made as a window-modal sheet and prompt-for-integer returns immediately, leaving the dialog on the screen. The with-dialog-results macro provides a convenient way to create a continuation function.

The prompter is created by passing text-input-pane to popup-confirmer. Arguments can be passed to the make-instance of the pane and the call to popup-confirmer using pane-args and popup-args respectively.

Example
(capi:prompt-for-integer "Enter an integer:")
(capi:prompt-for-integer "Enter an integer:" :max 10)
(capi:prompt-for-integer "Enter an integer:"
                         :min 100 :max 200)
(capi:prompt-for-integer "Enter an integer:"
                         :ok-check 'evenp)
See also

prompt-for-string
popup-confirmer
text-input-pane
Dialogs: Prompting for Input


CAPI User Guide and Reference Manual (Windows version) - 3 Aug 2017

NextPrevUpTopContentsIndex