Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tcl pause & waiting for key pressed to continue

Tags:

key

tcl

pressed

I'm looking for a way in tcl to pause the script (for example after some outputs with "puts") and wait for a key pressed from the user before continuing to output the remaining text.

like image 982
user2669068 Avatar asked Sep 24 '13 22:09

user2669068


People also ask

How do I stop a TCL script?

The end command can also be used to stop a TCL command that was sent to another line by the tcl command, or to terminate a phantom job. The end command clears an active list and requires a sys2 privilege level. If the port number and user-ID are not specified, the end command stops the process on the current line.

What is after in TCL?

The after command returns an identifier that can be used to cancel the delayed command using after cancel. after cancel id. Cancels the execution of a delayed command that was previously scheduled. Id indicates which command should be canceled; it must have been the return value from a previous after command.


1 Answers

You just use gets to read from stdin:

proc pause {{message "Hit Enter to continue ==> "}} {
    puts -nonewline $message
    flush stdout
    gets stdin
}

pause "Hurry, hit enter: "; # Sample usage 1
pause;                      # Sample usage 2, use default message
like image 126
Hai Vu Avatar answered Oct 02 '22 17:10

Hai Vu