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

Problem with wishx start script from http://wiki.tcl.tk/207

5 views
Skip to first unread message

Pierre Bernhardt

unread,
Jan 8, 2006, 8:18:31 AM1/8/06
to
Hello,

I'm beginner and have a problem to start some old wishx
scripts.
I've not found packages for my debian but have read I can
use a small script named wishx (from above site) to use
the old one with tcl tk and tclx:

#!/bin/sh
#\
exec wish "$0" ${1+"$@"}
package require Tk
package require Tclx
set args [lassign $args argv0]
source $argv0

But it didn't work at give only the following output:

Error in startup script: can't read "args": no such variable
while executing
"lassign $args argv0"
invoked from within
"set args [lassign $args argv0]"
(file "/usr/local/bin/wishx" line 6)

I understand that lassign needs $args, but it isn't set before
the command will executed. This means args will set first if
lassign is executed.

I mean the problem is that the example from the site is in error.

Any idea how I can fix it?

MfG...
Pierre

C. Plater

unread,
Jan 8, 2006, 8:58:49 AM1/8/06
to

Replace args with argv as in:


> #!/bin/sh
> #\
> exec wish "$0" ${1+"$@"}
> package require Tk
> package require Tclx

> set argv [lassign $argv argv0]
> source $argv0
From http://mini.net/tcl/207

Pierre Bernhardt

unread,
Jan 8, 2006, 9:26:29 AM1/8/06
to
C. Plater schrieb:

> Pierre Bernhardt wrote:
> Replace args with argv as in:

PEBKAC :-)

Thx...
Pierre

miguel sofer

unread,
Jan 8, 2006, 9:24:33 AM1/8/06
to
To set the record straight: the original wiki page had the error as
reported by Pierre.

I corrected the wiki page, but had trouble reporting that to the
newsgroup, and you are quoting the corrected page.

Miguel

miguel sofer

unread,
Jan 8, 2006, 8:56:13 AM1/8/06
to
Just replace

set args [lassign $args argv0]
with

set argv [lassign $argv argv0]

The page http://wiki.tcl.tk/207 is now corrected, thx for the report.

Both tclsh and wish have the "automatic" variavles argv0/argv where the
command line is stored. When you call
wishx myprog arg1 arg2
the wishx-script has the values
argv0=wishx argv= {myprog arg1 arg2}

The lassign-line sets them to the expected values
argv0=myprog argv={arg1 arg2}
before sourcing the myprog-script.

HTH
Miguel

miguel sofer

unread,
Jan 8, 2006, 8:51:06 AM1/8/06
to
The correct line should be

set argv [lassign $argv argv0]
(already fixed in http://wiki.tcl.tk/207, thx for the report).

Note that both tclsh and wish will store the command line arguments in
argv0/argv. When you call
wishx myprog arg1 arg2
the wishx script will have
$argv0=wishx, $argv=[list myprog arg1 arg2]

The corrected line will reset the values of those automatic variables
to
$argv0=myprog, $argv=[list arg1 arg2]
before sourcing myprog, which is what myprog is expecting.

HTH
Miguel

miguel sofer

unread,
Jan 8, 2006, 9:00:26 AM1/8/06
to
Just replace

set args [lassign $args argv0]
with

set argv [lassign $argv argv0]

The page http://wiki.tcl.tk/207 is now corrected, thx for the report.

Both tclsh and wish have the "automatic" variavles argv0/argv where the

command line is stored. When you call
wishx myprog arg1 arg2

miguel sofer

unread,
Jan 8, 2006, 9:22:13 AM1/8/06
to
Just replace

set args [lassign $args argv0]

miguel sofer

unread,
Jan 8, 2006, 8:58:22 AM1/8/06
to
Just replace

set args [lassign $args argv0]

Pierre Bernhardt

unread,
Jan 9, 2006, 2:59:05 PM1/9/06
to miguel sofer
miguel sofer schrieb:

> The page http://wiki.tcl.tk/207 is now corrected, thx for the report.
And I wonder me I'm stupid to read the page because it was
already correct and my eyes need glasses;-)

Thx...
Pierre

0 new messages