Anonymous user
User Input: Difference between revisions
→{{header|Tcl}}: more detail, more alternatives
(→{{header|AWK}}: comply with task requirement (75000)) |
(→{{header|Tcl}}: more detail, more alternatives) |
||
Line 484:
=={{header|Tcl}}==
===Getting Input via a GUI===
{{libheader|Tk}}
<lang tcl>
Alternatively, the content of the widget can be tied to a variable:
▲<lang tcl> pack [entry .e1 -textvar input]
▲ # show the content at any time by
▲ puts $input</lang>
The <tt>-validate</tt> option can be used to test the contents/edits of the widget at any time against any parameters (including testing <tt>string is integer</tt> when the user hits <Return> or such)
===Getting Input from the Command Line===
You can also just work with sending requests for information to the user's terminal...
<lang tcl>proc question {var message} {
upvar 1 $var v
puts -nonewline "$message: "
flush stdout
gets stdin $v
}
question name "What is your name"
question task "What is your quest"
question doom "What is the air-speed velocity of an unladen swallow"</lang>
=={{header|VBScript}}==
|