Accessing the tclkit executable in a starpack

42 views
Skip to first unread message

Paul

unread,
Jul 18, 2011, 2:17:49 PM7/18/11
to starkit
Hi,

I want to distribute a Tcl app as a starpack. The computer that it
will be used on won't have Tcl installed on it, but of course, Tcl
will be in the starpack.

What I want to do is, from a tcl script within the starpack, kick off
another tcl process, using the tcl interpreter contained within the
starpack.

If I could do something like [open "|internal_tclkit external.tcl" r
+], that would be great, where internal_tclkit is the tclkit contained
within the starpack, and external.tcl is a tcl script that resides
outside the starpack.

Is something like this possible?

Thanks,

Paul.

(Actually, I would prefer to be able to kick off another process using
the internal tclkit and also an internal tcl script, but I've already
found out that's not posiible.)

Neil

unread,
Jul 19, 2011, 11:45:57 PM7/19/11
to starkit
If I understand you correctly, you can launch both of those using the
starpack.

Make a folder structure (mine has main.tcl in the root, with a /lib
below that).

---- main.tcl ----
package require starkit

if {[llength $::argv]==1 && [string length [lindex $::argv 0]] &&
[file exist [lindex $::argv 0]]} {
source [lindex $::argv 0]
exit
}

puts "Running remainder of script"
---- /main.tcl ----

Then put a 'hello world' script in the lib directory (i named it
int.tcl, and made a copy outside the whole thing called ext.tcl).

Pack it all up into an exe. If I run that as follows, I get this:

C:\dev\tcl\template>extlaunch.exe ext.tcl
hello

C:\dev\tcl\template>extlaunch.exe extlaunch.exe/lib/int.tcl
hello

Note, to run the internal file, you use the exe name as the base
directory...

Next, if you want to open a new process from your exe running one of
the scripts, you just change the 'Running remainder of script' line
with:
exec [info nameofexecutable] ext.tcl
or
exec [info nameofexecutable] [file join [info nameofexecutable] lib
int.tcl]

You'd probably be best off using cmdline for the options, and
accepting a -source option, or similar, and obviously you want to
merge this with a proper main.tcl; but essentially, all you do is
source/exec the script *if it's passed*, then exit; or go on with your
app otherwise.
Reply all
Reply to author
Forward
0 new messages