User Input: Difference between revisions
Content added Content deleted
(→{{header|AWK}}: comply with task requirement (75000)) |
(→{{header|Tcl}}: more detail, more alternatives) |
||
Line 484: | Line 484: | ||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
===Getting Input via a GUI=== |
|||
{{libheader|Tk}} |
{{libheader|Tk}} |
||
<lang tcl> |
<lang tcl># create entry widget: |
||
pack [entry .e1] |
|||
# read its content: |
|||
set input [.e get]</lang> |
|||
Alternatively, the content of the widget can be tied to a variable: |
Alternatively, the content of the widget can be tied to a variable: |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
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) |
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}}== |
=={{header|VBScript}}== |