Short description: the app is divided into a couple of components: the
main (GUI) part, and a couple of helper scripts that implement
under-the-hood functionality. I call the helper scripts via "open |" and
fileevent. The scripts themselves are set as executable and are executed
by the system-installed tclsh (#!/usr/bin/tclsh). I developed this
design to keep the GUI from locking up while the helper processes ran.
Because Windows doesn't have tclsh installed, what's the best way to
achieve the functionality I'm looking for? The only thing I can think of
is to wrap each script separately. I read about Winserv at the wiki, but
that seems too complex for my needs.
Any other ideas?
Well, if your app is running there's obviously a tcl interpreter
available, right? Just re-exec your own executable. Or is there a reason
that won't work?
The other option is to use threads and run your helper procs in a thread
of the existing executable rather than as separate processes.
proc main argv {
switch -- [lindex $argv 0] {
this {puts hello; exit}
that {puts world; exit}
{} {# no arguments, main instance
puts "[exec [info na] $::argv0 this], [exec [info na] $::argv0
that]!"
}
}
}
main $argv
----
For testing this as a script in normal tclsh, I had to add the $::argv0
script name. In a wrapped executable, you may not need it - just [puts
$argv] to find out how it is called.
It is a single file equivalent to a full tcl install
for tclsh.exe
Put the freewrap thingy into your wrap and
unpack it at install. Done.
>
> Any other ideas?
>
>>
>
> Well, if your app is running there's obviously a tcl interpreter
> available, right? Just re-exec your own executable. Or is there a reason
> that won't work?
Hmmm. That's so blindingly obvious I didn't think of it.
Using code like this:
set exectool [info nameofexecutable]
set helpertool [file join [file dirname [info script] ] footool.tcl]
works fine on the Mac, and I'm sure it would work equally well on Windows.
An interpreter recursively calling itself and opening a pipe to
itself...cool.
Thanks!