diff options
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | main.tcl | 14 |
2 files changed, 17 insertions, 1 deletions
@@ -13,3 +13,7 @@ Folk.app: rm -r /tmp/folk.vfs; mkdir /tmp/folk.vfs cp -r * /tmp/folk.vfs cd /tmp; tclsh ~/Downloads/sdx*kit wrap folk -runtime $(TCLKIT) + +NODE := localhost +view-statements: + echo viewStatements | nc $(NODE) 4273 @@ -102,6 +102,16 @@ proc evaluate {} { } +# pretty-prints latest statement set +proc viewStatements {} { + return [join [lmap statement [dict keys $::statements] { + lmap word $statement {expr { + [string length $word] > 20 ? + "[string range $word 0 20]..." : + $word + }} + }] "\n"] +} proc accept {chan addr port} { # (mostly for the Pi) # we want to be able to asynchronously receive statements @@ -109,8 +119,10 @@ proc accept {chan addr port} { while {[gets $chan line] != -1} { append script $line\n if {[info complete $script]} { - catch { + if {[catch { puts $chan [eval $script]; flush $chan + } ret]} { + puts $chan $ret; flush $chan } set script "" } |
