Version 0 of Breakpoints in Tcl

Updated 2014-05-05 19:08:06 by hypnotoad

On facebook someone asked "how do you stop tcl script at a particular line"

The quickest way, if you know the line is (immediately before that line):

error "I have to stop here"

But if you are looking for something a little more elegant, create a proc which tells Tcl to enter the event loop, and stay there until a condition has been satisfied. In this case we will assume our program is running from a command line, and we want to prompt the user to press any key to continue.

proc breakpoint {} { 
  set ::breakpoint 0
  puts stdout "Press <Any Key> to continue"
  fileevent stdin readable {set ::breakpoint 1}
  vwait ::breakpoint