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 19:03, 28 June 2011
, 12 years agoTcl version without a console
(Tcl version without a console) |
|||
Line 244:
=={{header|Tcl}}==
Using the console (expects U*Xish <tt>stty</tt>)
<lang tcl>proc yesno {{message "Press Y or N to continue"}} {
fconfigure stdin -blocking 0
Line 261 ⟶ 264:
set yn [yesno "Do you like programming (Y/N)"]</lang>
Without a console (answer in the global variable yn; this should work in any GUI for which there is a TCL):
<lang tcl>
proc yesno {message} {
toplevel .msg
pack [label .msg.l -text "$message\n (type Y/N)?"]
set ::yn ""
bind .msg <Key-y> {set ::yn "Y"}
bind .msg <Key-n> {set ::yn "N"}
vwait ::yn
destroy .msg
}
yesno "Do you like programming?"
</lang>
{{omit from|PARI/GP}}
|