Problem when opening a pipe to read&write

View: New views
1 Messages — Rating Filter:   Alert me  

Problem when opening a pipe to read&write

by Tommaso Vinci :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear all, I have uploaded a version of the problem I get whaen opening a pipe to an application.
Here is the zipped version of the Test.app tree:

the error on the console is
channel "console1" wasn't opened for writing
    while executing
"open "| /sw/bin/gnuplot 2>@stdout" w+ "
    invoked from within
"set gnuplot [ open "| /sw/bin/gnuplot 2>@stdout" w+ ]"
    (file "/Users/tommaso/local/tmp/Test.app/Contents/Resources/Scripts/test.tcl" line 18)
    invoked from within
"source [file join [file dirname [info script]] test.tcl]"

Can someone explain me this?
of course the script plays well when invoked from inside a terminal

Here is the script inside the test.app tree:

proc control {fp} {
  set linea [gets $fp]
  if {[eof $fp] || $linea == ""} {
    fileevent $fp readable ""
    after 300 [list fileevent $fp readable "control $fp"]
  } else {
    set value ""
    scan $linea "%s" value
    switch -exact -- "$value" {
      "changetosin" {
        global var
        set var "plot sin(x)"
      }
    }
  }
}

set gnuplot [ open "| /sw/bin/gnuplot 2>@stdout" w+ ]
puts $gnuplot "plot x"
puts $gnuplot {bind s 'print "changetosin"'}
flush $gnuplot
fileevent $gnuplot readable {control $gnuplot}

set var "plot x**2"

button .b -text "calculate" -command {puts $gnuplot $var; flush $gnuplot}
entry .e -textvariable var
pack .b .e




--
Tommaso Vinci
LULI - Ecole Polytechnique
+33 (0)1 69335427
tommaso.vinci@...
http://www.luli.polytechnique.fr

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcl-mac mailing list
tcl-mac@...
https://lists.sourceforge.net/lists/listinfo/tcl-mac