Posted to tcl by bicepjai at Wed Jun 16 02:29:10 GMT 2010view raw

  1.  
  2.  
  3. fileevent stdin readable [list data stdin]
  4. fconfigure stdin -blocking 0
  5. fconfigure stdout -buffering line
  6.  
  7. proc data {fd} {
  8. if {[eof $fd]} {
  9. exit
  10. } elseif {[gets $fd line]} {
  11. puts "$line"
  12. if {$line eq "quit"} {
  13. exit
  14. } elseif {$line eq "pause"} {
  15. set ::counter 0
  16. } elseif {$line eq "resume"} {
  17. set ::counter 0
  18. }
  19. }
  20. }