Keyboard input/Obtain a Y or N response: Difference between revisions
Content added Content deleted
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
No edit summary |
||
Line 2,010: | Line 2,010: | ||
You typed: Y |
You typed: Y |
||
</pre> |
</pre> |
||
=={{header|SparForte}}== |
|||
As a structured script. |
|||
<syntaxhighlight lang="ada">#!/usr/local/bin/spar |
|||
pragma annotate( summary, "yorn" ); |
|||
pragma annotate( description, "Obtain a valid Y or N response from the keyboard. The" ); |
|||
pragma annotate( description, "keyboard should be flushed, so that any outstanding keypresses" ); |
|||
pragma annotate( description, "are removed, preventing any existing Y or N keypress from" ); |
|||
pragma annotate( description, "being evaluated. The response should be obtained as soon as" ); |
|||
pragma annotate( description, "Y or N are pressed, and there should be no need to press an" ); |
|||
pragma annotate( description, "enter key. " ); |
|||
pragma annotate( see_also, "http://rosettacode.org/wiki/Keyboard_Input/Obtain_a_Y_or_N_response" ); |
|||
pragma annotate( author, "Ken O. Burtch" ); |
|||
pragma ada_95; |
|||
pragma restriction( no_external_commands ); |
|||
procedure yorn is |
|||
answer : character; |
|||
begin |
|||
put( "Your answer? (Y/N) " ); |
|||
loop |
|||
answer := inkey; |
|||
case answer is |
|||
when 'Y'|'y' => |
|||
answer := 'Y'; |
|||
exit; |
|||
when 'N'|'n' => |
|||
answer := 'N'; |
|||
exit; |
|||
when others => |
|||
null; |
|||
end case; |
|||
end loop; |
|||
put_line( answer ); |
|||
end yorn;</syntaxhighlight> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |