Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

running a TCL/tk program in different modes

45 views
Skip to first unread message

Mark Tarver

unread,
Jan 31, 2024, 1:58:51 AMJan 31
to
I have now constructed a batch file that enables me to run two communicating processes - in principle. The problem now is the way the TCL process is run. Here is the manual way I'm having to do it.

1. Start TCL/Tk by clicking on WISH which gives me a console window.
2. Load eventloop.tcl using the console (process A).
3. Optionally, kill the console.
4. Open sbcl-shen.exe (process B, with the communicating program preloaded).

This works. However if I vary this routine as follows.

1. Load eventloop.tcl by clicking on it (process A).
2. Open sbcl-shen.exe (process B, with the communicating program preloaded).

Then I get two windows but process B cannot talk to process A. This two step routine is the routine in my Windows batch file.

Mark

et99

unread,
Jan 31, 2024, 4:25:14 AMJan 31
to
From the sound of the file name, eventloop.tcl, is this a small piece of tcl code you're experimenting with? Can you post this file?

And the .exe, what is that? Do you have its source code; what language is it? What does comm prog preloaded mean? Is it a tclkit/starpak or something else.

Mark Tarver

unread,
Jan 31, 2024, 6:38:40 AMJan 31
to
TCL, yes sure. The exe file is a saved SBCL (Lisp) image holding a port of the Shen language.

# TCL event loop

set in {C:/Users/shend/OneDrive/Desktop/Shen/S38/shen-to-tcl.txt}
set out {C:/Users/shend/OneDrive/Desktop/Shen/S38/tcl-to-shen.txt}

proc eventloop {File} {
while { 1 } {
after 10
if { [newcommand? $File] } {
enact $File }
update }}

proc newcommand? {File} {
set Source [open $File r]
set Data [read $Source]
set Verdict [eot? $Data]
close $Source
return $Verdict}

proc eot? {S} {
return [ string match *eot $S ]
}

proc enact {File} {
set Source [open $File r]
set Data [read $Source]
set Command [trim $Data]
overwrite $File
if { [catch $Command result] != 0 } then {
err $result}
close $Source}

proc overwrite {File} {
set Sink [open $File w]
puts -nonewline $Sink ""
flush $Sink
close $Sink}

proc trim {S} {
return [string map {"eot" ""} $S]
}

proc mysend {String} {
global out
set Sink [open $out w]
puts $Sink [concat $String "eot"]
close $Sink}

proc err {String} {
set Format [myformat $String]
mysend [concat "(error \"" $Format "\")"]}

proc myformat {String} {
return [string map {\" ""} $String]}

eventloop $in

Mark Tarver

unread,
Jan 31, 2024, 7:31:46 AMJan 31
to
On Wednesday 31 January 2024 at 09:25:14 UTC, et99 wrote:
Nailed it. The problem is in the batch file. I now have

START /B sbcl-shen.exe
C:\ActiveTcl\bin\wish.exe "C:\Users\shend\OneDrive\Desktop\Shen\S38\Tk\eventloop.tcl"

I was using C:\ActiveTcl\bin\wish86t.exe

Mark

et99

unread,
Jan 31, 2024, 1:14:42 PMJan 31
to
Glad to hear it. For future reference, I would recommend you get process explorer from here:

https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer

It's much better tool than windows task manager. I run it at startup so I always have it available.

In your case, it would have been useful to tell you exactly what the resulting command line is when you (double) click a .tcl file. It can also display the process hierarchy, and the working directory that a program starts up in. You can also get visibility into what files it is opening.

No windows programmer should be without it.




0 new messages