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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With