Anonymous user
Keyboard input/Obtain a Y or N response: Difference between revisions
Keyboard input/Obtain a Y or N response (view source)
Revision as of 16:29, 15 October 2010
, 13 years ago→Tcl: Added implementation
m (→{{header|PureBasic}}: Cleaned up code & improved comments) |
(→Tcl: Added implementation) |
||
Line 30:
Until Key$="Y" Or Key$="N"
PrintN("The response was "+Key$)</lang>
=={{header|Tcl}}==
<lang tcl>proc yesno {{message "Press Y or N to continue"}} {
fconfigure stdin -blocking 0
exec stty raw
read stdin ; # flush
puts -nonewline "${message}: "
flush stdout
while {![eof stdin]} {
set c [string tolower [read stdin 1]]
if {$c eq "y" || $c eq "n"} break
}
puts [string toupper $c]
exec stty -raw
fconfigure stdin -blocking 1
return [expr {$c eq "y"}]
}
set yn [yesno "Do you like programming (Y/N)"]</lang>
|