User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:y-or-n-p [2019/11/11 05:00]
cl:functions:y-or-n-p [2019/11/22 14:00] (current)
Line 1: Line 1:
 +====== Function Y-OR-N-P, YES-OR-NO-P ======
 +
 +====Syntax====
 +  * **y-or-n-p** ''&​optional''​ //control// ''&​rest //​arguments//​ → //​generalized-boolean// ​
 +  * **yes-or-no-p**{''&​optional''​ //control// ''&​rest //​arguments//​ → //​generalized-boolean//​
 +
 +====Arguments and Values====
 +//control// - a //​[[CL:​Glossary:​format control]]//​.
 +
 +//​arguments//​ - //​[[CL:​Glossary:​format arguments]]//​ for //​control//​.
 +
 +//​generalized-boolean//​ - a //​[[CL:​Glossary:​generalized boolean]]//​.
 +
 +====Description====
 +These functions ask a question and parse a response from the user. They return //​[[CL:​Glossary:​true]]//​ if the answer is affirmative,​ or //​[[CL:​Glossary:​false]]//​ if the answer is negative.
 +
 +**y-or-n-p** is for asking the user a question whose answer is either "​yes"​ or "​no."​ It is intended that the reply require the user to answer a yes-or-no question with a single character.
 +
 +**yes-or-no-p** is also for asking the user a question whose answer is either "​Yes"​ or "​No."​ It is intended that the reply require the user to take more action than just a single keystroke, such as typing the full word ''​yes''​ or ''​no''​ followed by a newline.
 +
 +**y-or-n-p** types out a message (if supplied), reads an answer in some //​[[CL:​Glossary:​implementation-dependent]]//​ manner (intended to be short and simple, such as reading a single character such as ''​Y''​ or ''​N''​). **yes-or-no-p** types out a message (if supplied), attracts the user's attention (for example, by ringing the terminal'​s bell), and reads an answer in some //​[[CL:​Glossary:​implementation-dependent]]//​ manner (intended to be multiple characters, such as ''​YES''​ or ''​NO''​).
 +
 +If //​format-control//​ is supplied and not **[[CL:​Constant Variables:​nil]]**,​ then a **[[CL:​Functions:​fresh-line]]** operation is performed; then a message is printed as if //​format-control//​ and //​arguments//​ were given to **[[CL:​Functions:​format]]**. In any case, **yes-or-no-p** and **y-or-n-p** will provide a prompt such as ""​(Y or N)''''​ or ""​(Yes or No)''''​ if appropriate.
 +
 +All input and output are performed using //​[[CL:​Glossary:​query I/O]]//.
 +
 +====Examples====
 +<​blockquote> ​
 +(y-or-n-p "(t or nil) given by")
 +<r>(t or nil) given by (Y or N) __Y__ </r>
 +<​r>//​[[CL:​Glossary:​true]]//​ </r>
 +(yes-or-no-p "a ~S message"​ '​frightening)
 +<r>a FRIGHTENING message (Yes or No) __no__ </r>
 +<​r>//​[[CL:​Glossary:​false]]//​ </r>
 +(y-or-n-p "​Produce listing file?"​)
 +<​o>​Produce listing file?
 +Please respond with Y or N. __n__ </o>
 +<​r>//​[[CL:​Glossary:​false]]//</​r>​
 +</​blockquote>​
 +
 +====Side Effects====
 +Output to and input from //​[[CL:​Glossary:​query I/O]]// will occur.
 +
 +====Affected By====
 +**[[CL:​Variables:​star-query-io-star|*query-io*]]**.
 +
 +====Exceptional Situations====
 +None.
 +
 +====See Also====
 +  * **[[CL:​Functions:​format|Function FORMAT]]**
 +
 +====Notes====
 +**yes-or-no-p** and **yes-or-no-p** do not add question marks to the end of the prompt string, so any desired question mark or other punctuation should be explicitly included in the text query.
 +
 +\issue{FORMAT-STRING-ARGUMENTS:​SPECIFY}