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
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
PEBKAC :-)
Thx...
Pierre
I corrected the wiki page, but had trouble reporting that to the
newsgroup, and you are quoting the corrected page.
Miguel
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
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
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
Thx...
Pierre