Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.20 KB | None | 0 0
  1.     fconfigure $pd_socket -blocking 0 -buffering line -buffersize 1000000 -encoding utf-8;
  2.     fileevent $pd_socket readable {::pd_connect::pd_readsocket ""}
  3.  
  4. proc ::pd_connect::pd_readsocket {cmd_from_pd} {
  5.     variable pd_socket
  6.     if {[eof $pd_socket]} {
  7.         # if we lose the socket connection, that means pd quit, so we quit
  8.         close $pd_socket
  9.         exit
  10.     }
  11.     while {[gets $pd_socket line] > -1} {
  12.         puts -nonewline stderr "A"
  13.         append cmd_from_pd $line\n
  14.     }
  15.     if {[string index $cmd_from_pd end] eq "\\"} {
  16.         puts -nonewline stderr "\\"
  17.         pd_readsocket $cmd_from_pd
  18.     } else {
  19.         puts -nonewline stderr "e"
  20.         if {[catch {uplevel #0 $cmd_from_pd} errorname]} {
  21.             global errorInfo
  22.             switch -regexp -- $errorname {
  23.                 "missing close-brace" {
  24.                     pd_readsocket $cmd_from_pd
  25.                 } "^invalid command name" {
  26.                     ::pdwindow::fatal [concat [_ "(Tcl) INVALID COMMAND NAME: "] $errorInfo "\n"]
  27.                 } default {
  28.                     ::pdwindow::fatal [concat [_ "(Tcl) UNHANDLED ERROR: "] $errorInfo "\n"]
  29.                 }
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement