From: Richard Owlett on
My OS is WinXP Pro Service Pack 2
I have Tcl versions 8.4.14.0 and 8.5.2.0 from ActiveState installed.
Goal is to run Gnuplot commands from Tcl (eventually with the
Tcl interpreter packaged with Scilab 4.1.2 [reports "TCL/TK 8.4.15
Final Release"]).
I frequently use "TclTutor 3.0 Beta 2" as test bed for scripts because
its error highliting scheme is helpful.

My script (based on sample in TWAPI documentation) is:

# Send a text string to existing gnuplot window
package require twapi

set title gnuplot
set data "plot 'C:\dataset1.dat' using 1:3 \n"

# Get all windows with that title
set windows [twapi::find_windows -text $title]
if {[llength $windows]} {
set win [lindex $windows 0]
# Set the focus to the window
twapi::set_focus $win
# Feed data in to the input queue
twapi::send_input_text $data
} else {
puts "No windows found with title '$title'"
}


This script runs fine when run from TclTutor. Tested with and without
the gnuplot window existing.

It fails when run from Wish85, Tclsh85, Wish84, or Tclsh84.
All 4 react the same.
If no gnuplot window exists, that is correctly reported.
If the gnuplot window does exist, the contents of $data appear in the
Wish/Tclsh window.

*This morning* it runs correctly under Scilab IF the gnuplot window
exists. It [as might be expected] fails silently if the gnuplot window
does not exist. I don't recall it working from Scilab at all *last night* ;/

I'm a Tcl newbie. What perfectly obvious thing am I missing?
TIA





From: Alexandre Ferrieux on
On 13 déc, 14:06, Richard Owlett <rowl...(a)atlascomm.net> wrote:
> My OS is WinXP Pro Service Pack 2
> I have Tcl versions 8.4.14.0 and 8.5.2.0 from ActiveState installed.
>      Goal is to run Gnuplot commands from Tcl (eventually with the
>      Tcl interpreter packaged with Scilab 4.1.2 [reports "TCL/TK 8.4.15
>      Final Release"]).
> I frequently use "TclTutor 3.0 Beta 2" as test bed for scripts because
> its error highliting scheme is helpful.
>
> My script (based on sample in TWAPI documentation) is:
>
> # Send a text string to existing gnuplot window
> package require twapi
>
> set title gnuplot
> set data "plot 'C:\dataset1.dat' using 1:3 \n"
>
> # Get all windows with that title
> set windows [twapi::find_windows -text $title]
> if {[llength $windows]} {
>      set win [lindex $windows 0]
>      # Set the focus to the window
>      twapi::set_focus $win
>      # Feed data in to the input queue
>      twapi::send_input_text $data} else {
>
>      puts "No windows found with title '$title'"
>
> }
>
> This script runs fine when run from TclTutor. Tested with and without
> the gnuplot window existing.
>
> It fails when run from Wish85, Tclsh85, Wish84, or Tclsh84.
> All 4 react the same.
> If no gnuplot window exists, that is correctly reported.
> If the gnuplot window does exist, the contents of $data appear in the
> Wish/Tclsh window.
>
> *This morning* it runs correctly under Scilab IF the gnuplot window
> exists. It [as might be expected] fails silently if the gnuplot window
> does not exist. I don't recall it working from Scilab at all *last night* ;/
>
> I'm a Tcl newbie. What perfectly obvious thing am I missing?
> TIA

Hmm, looks you were a bit quick to abandon pipes ;-)

FWIW, after an admittedly longer-than-expected Google session, I found
that using gnuplot through pipes on Windows works like a charm..
provided you know which executable to launch !
The key is that the proper exe is "pgnuplot.exe", not wgnuplot_pipes
which is a decoy ;-)

The following works out of the box in an interactive tclsh/wish:

# assume you set up the PATH to see pgnuplot.exe
set ff [open "|pgnuplot" r+]
fconfigure $ff -buffering line
puts $ff "plot sin(x)"

Of course If you want a more "fire-and-forget" behavior (let Tcl
prepare something to display then let gnuplot live alone), use
"pgnuplot -persist".

HTH,

-Alex


From: Richard Owlett on
Alexandre Ferrieux wrote:
> On 13 d�c, 14:06, Richard Owlett <rowl...(a)atlascomm.net> wrote:
>
>>My OS is WinXP Pro Service Pack 2
>>I have Tcl versions 8.4.14.0 and 8.5.2.0 from ActiveState installed.
>> Goal is to run Gnuplot commands from Tcl (eventually with the
>> Tcl interpreter packaged with Scilab 4.1.2 [reports "TCL/TK 8.4.15
>> Final Release"]).
>>I frequently use "TclTutor 3.0 Beta 2" as test bed for scripts because
>>its error highliting scheme is helpful.
>>
>>My script (based on sample in TWAPI documentation) is:
>>
>># Send a text string to existing gnuplot window
>>package require twapi
>>
>>set title gnuplot
>>set data "plot 'C:\dataset1.dat' using 1:3 \n"
>>
>># Get all windows with that title
>>set windows [twapi::find_windows -text $title]
>>if {[llength $windows]} {
>> set win [lindex $windows 0]
>> # Set the focus to the window
>> twapi::set_focus $win
>> # Feed data in to the input queue
>> twapi::send_input_text $data} else {
>>
>> puts "No windows found with title '$title'"
>>
>>}
>>
>>This script runs fine when run from TclTutor. Tested with and without
>>the gnuplot window existing.
>>
>>It fails when run from Wish85, Tclsh85, Wish84, or Tclsh84.
>>All 4 react the same.
>>If no gnuplot window exists, that is correctly reported.
>>If the gnuplot window does exist, the contents of $data appear in the
>>Wish/Tclsh window.
>>
>>*This morning* it runs correctly under Scilab IF the gnuplot window
>>exists. It [as might be expected] fails silently if the gnuplot window
>>does not exist. I don't recall it working from Scilab at all *last night* ;/
>>
>>I'm a Tcl newbie. What perfectly obvious thing am I missing?
>>TIA
>
>
> Hmm, looks you were a bit quick to abandon pipes ;-)

*ROFL* !!!
Hey, if a half century younger, I would have been diagnosed as ADHD.
Besides, TWAPI will likely be very useful in another project.
And one learns patience having run CUPL on CORC with 026 input device.


>
> FWIW, after an admittedly longer-than-expected Google session,

You mean I'm not the only one to discover that
[google == " fascinating rabbit trails"]

Could you list the URL's you found useful? TIA

> I found
> that using gnuplot through pipes on Windows works like a charm..
> provided you know which executable to launch !
> The key is that the proper exe is "pgnuplot.exe", not wgnuplot_pipes
> which is a decoy ;-)
>
> The following works out of the box in an interactive tclsh/wish:
>
> # assume you set up the PATH to see pgnuplot.exe
> set ff [open "|pgnuplot" r+]
> fconfigure $ff -buffering line
> puts $ff "plot sin(x)"
>

I'll try it.


> Of course If you want a more "fire-and-forget" behavior (let Tcl
> prepare something to display then let gnuplot live alone), use
> "pgnuplot -persist".
>
> HTH,
>
> -Alex
>
>

But, you didn't answer the question of this thread ;)
From: Richard Owlett on
Richard Owlett wrote:
> Alexandre Ferrieux wrote:
>
>> On 13 d�c, 14:06, Richard Owlett <rowl...(a)atlascomm.net> wrote:
>>
>>> My OS is WinXP Pro Service Pack 2
>>> I have Tcl versions 8.4.14.0 and 8.5.2.0 from ActiveState installed.
>>> Goal is to run Gnuplot commands from Tcl (eventually with the
>>> Tcl interpreter packaged with Scilab 4.1.2 [reports "TCL/TK 8.4.15
>>> Final Release"]).
>>> I frequently use "TclTutor 3.0 Beta 2" as test bed for scripts because
>>> its error highliting scheme is helpful.
>>>
>>> My script (based on sample in TWAPI documentation) is:
>>>
>>> # Send a text string to existing gnuplot window
>>> package require twapi
>>>
>>> set title gnuplot
>>> set data "plot 'C:\dataset1.dat' using 1:3 \n"
>>>
>>> # Get all windows with that title
>>> set windows [twapi::find_windows -text $title]
>>> if {[llength $windows]} {
>>> set win [lindex $windows 0]
>>> # Set the focus to the window
>>> twapi::set_focus $win
>>> # Feed data in to the input queue
>>> twapi::send_input_text $data} else {
>>>
>>> puts "No windows found with title '$title'"
>>>
>>> }
>>>
>>> This script runs fine when run from TclTutor. Tested with and without
>>> the gnuplot window existing.
>>>
>>> It fails when run from Wish85, Tclsh85, Wish84, or Tclsh84.
>>> All 4 react the same.
>>> If no gnuplot window exists, that is correctly reported.
>>> If the gnuplot window does exist, the contents of $data appear in the
>>> Wish/Tclsh window.
>>>
>>> *This morning* it runs correctly under Scilab IF the gnuplot window
>>> exists. It [as might be expected] fails silently if the gnuplot window
>>> does not exist. I don't recall it working from Scilab at all *last
>>> night* ;/
>>>
>>> I'm a Tcl newbie. What perfectly obvious thing am I missing?
>>> TIA
>>
>>
>>
>> Hmm, looks you were a bit quick to abandon pipes ;-)
>
>
> *ROFL* !!!
> Hey, if a half century younger, I would have been diagnosed as ADHD.
> Besides, TWAPI will likely be very useful in another project.
> And one learns patience having run CUPL on CORC with 026 input device.
>
>
>>
>> FWIW, after an admittedly longer-than-expected Google session,
>
>
> You mean I'm not the only one to discover that
> [google == " fascinating rabbit trails"]
>
> Could you list the URL's you found useful? TIA
>
>> I found
>> that using gnuplot through pipes on Windows works like a charm..
>> provided you know which executable to launch !
>> The key is that the proper exe is "pgnuplot.exe", not wgnuplot_pipes
>> which is a decoy ;-)
>>
>> The following works out of the box in an interactive tclsh/wish:
>>
>> # assume you set up the PATH to see pgnuplot.exe
>> set ff [open "|pgnuplot" r+]
>> fconfigure $ff -buffering line
>> puts $ff "plot sin(x)"
>>
>
> I'll try it.

It works from Wish and Tclsh.
It has problems when trying to use Silab's Tcl/Tk functionality. I
believe the problem is proper usage of mixing use of ' ' within " ".
I get a Scilab error.

I suspect I experienced the same thing with my TWAPI runs. Why this
morning's run with Scilab worked and last night's didn't. And I've
misfiled the relevant Scilab scripts ;<

>
>
>> Of course If you want a more "fire-and-forget" behavior (let Tcl
>> prepare something to display then let gnuplot live alone), use
>> "pgnuplot -persist".
>>
>> HTH,
>>
>> -Alex
>>
>>
>
> But, you didn't answer the question of this thread ;)
From: Alexandre Ferrieux on
On 13 déc, 15:54, Richard Owlett <rowl...(a)atlascomm.net> wrote:
> Alexandre Ferrieux wrote:
> > On 13 déc, 14:06, Richard Owlett <rowl...(a)atlascomm.net> wrote:
>
> >>My OS is WinXP Pro Service Pack 2
> >>I have Tcl versions 8.4.14.0 and 8.5.2.0 from ActiveState installed.
> >>     Goal is to run Gnuplot commands from Tcl (eventually with the
> >>     Tcl interpreter packaged with Scilab 4.1.2 [reports "TCL/TK 8.4.15
> >>     Final Release"]).
> >>I frequently use "TclTutor 3.0 Beta 2" as test bed for scripts because
> >>its error highliting scheme is helpful.
>
> >>My script (based on sample in TWAPI documentation) is:
>
> >># Send a text string to existing gnuplot window
> >>package require twapi
>
> >>set title gnuplot
> >>set data "plot 'C:\dataset1.dat' using 1:3 \n"
>
> >># Get all windows with that title
> >>set windows [twapi::find_windows -text $title]
> >>if {[llength $windows]} {
> >>     set win [lindex $windows 0]
> >>     # Set the focus to the window
> >>     twapi::set_focus $win
> >>     # Feed data in to the input queue
> >>     twapi::send_input_text $data} else {
>
> >>     puts "No windows found with title '$title'"
>
> >>}
>
> >>This script runs fine when run from TclTutor. Tested with and without
> >>the gnuplot window existing.
>
> >>It fails when run from Wish85, Tclsh85, Wish84, or Tclsh84.
> >>All 4 react the same.
> >>If no gnuplot window exists, that is correctly reported.
> >>If the gnuplot window does exist, the contents of $data appear in the
> >>Wish/Tclsh window.
>
> >>*This morning* it runs correctly under Scilab IF the gnuplot window
> >>exists. It [as might be expected] fails silently if the gnuplot window
> >>does not exist. I don't recall it working from Scilab at all *last night* ;/
>
> >>I'm a Tcl newbie. What perfectly obvious thing am I missing?
> >>TIA
>
> > Hmm, looks you were a bit quick to abandon pipes ;-)
>
> *ROFL* !!!
> Hey, if a half century younger, I would have been diagnosed as ADHD.
> Besides, TWAPI will likely be very useful in another project.
> And one learns patience having run CUPL on CORC with 026 input device.
>
>
>
> > FWIW, after an admittedly longer-than-expected Google session,
>
> You mean I'm not the only one to discover that
> [google == " fascinating rabbit trails"]
>
> Could you list the URL's you found useful? TIA

I found

http://www.nabble.com/names-of-gnuplot-Win32-binaries-td20437476.html

by typing "wgnuplot_pipes" in Google Groups search and then sorting by
date.

> > The following works out of the box in an interactive tclsh/wish:
>
> I'll try it.
> But, you didn't answer the question of this thread ;)

Yes, because I think that switching to a nonportable method to make
two open-source, OS-agnostic tools talk together should buy you a room
number in Alcatraz ;-)

-Alex