Reading keyboard without waiting for [return]
Posted by enquirer (enquirer), 20 September 2004How do you get the program to check an input for being available without waiting for an input - I have used the command you used for the keypad input:
but it waits for an input before continuing so if there is no input, the 'exit' button can't be used and the program locks. (ctl-C to exit is not acceptable! especially if it is a wish program) also I am not waiting for a CR before processing the data.
Posted by admin (Graham Ellis), 20 September 2004There's an issue here with information getting through the operating system. In most circumstances, you'll NOT wish to read the keyboard until a new line is entered; if the user enters 2-3-backspace-4-return you'll only want to get 2-4 into your Tcl program, so that's the way it works. The operating system figures out that one the user presses [c/r], that's the equivalent of confirming to an "ru sure" and proceeds.
The easiest solution is to use Expect - an extension to Tcl and Tcl/Tk which does get the raw data in. However, I know this might not be the ideal solution for this particular poster so I'll have a look at other ideas too and follow up further.
Edit - additional follow up:
Certainly if your change -buffering 1 to - buffering 0 it'll be a step in the right direction; see my other post just made about similar control on the RS232 ports.
Other Forum Posts
Follow us on ...
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho