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

cant get wish to execute script

107 views
Skip to first unread message

lokiofa...@gmail.com

unread,
Nov 3, 2018, 5:34:02 PM11/3/18
to
Hi all-

I am using cygwin and windows. I am doing a C API script that Ralph helped me on. I can get wish to launch but it doesn't execute the tcl script. I might that I installed tcl in c:/ActiveTcl/bin and not as part of cygwin.

This is just a test script that does not launch the wish interpreter when the
"$0" ${1+"$@"} is added on to the exec wish line.

#!/cygdrive/c/cgwin64/bin/sh

exec wish "$0" ${1+"$@"}

button .b -text "Hello World" -command exit
pack .b

I register a command in Tcl and call it with:

interp=Tcl_CreateInterp();
Tcl_CreateObjCommand(interp, "lst" ,GetListCmd,(ClientData)NULL,(Tcl_CmdDeleteProc *)NULL);
// register command
cout << argv[1];

code=Tcl_EvalFile(interp,argv[1]);
result = Tcl_GetStringResult(interp);
cout << endl <<"COMMAND CREATED" << endl;

//result = Tcl_EvalObjEx(interp,script,0); // calls lst command

if (result!=TCL_OK) {
printf("Error was %s\n",result);

The error I get in mintty is:

mister-201@LAPTOP-HT7A13B8 ~/swigwin-3.0.12/proj1
$ ./foo.exe ./mylistbox.tcl

ARRIVING IN MAIN
./mylistbox.tcl
COMMAND CREATED
Error was can't read "0": no such variable
SCRIPT EVALUATED

Like this, the wish interpreter appears, but obviously the script does not run.

#!/cygdrive/c/cgwin64/bin/sh

exec wish

button .b -text "Hello World" -command exit
pack .b

How can I get wish to execute the hello world test script?

Please let me know if there is any easy fix.

I got soci running and the C API to create lists. Now I am trying to pass the list from sql to a listbox control.

If I can launch the test script, I think that soon I will have my small project working as a basis to doing some soci from Tcl.

thx.



lokiofa...@gmail.com

unread,
Nov 3, 2018, 5:47:30 PM11/3/18
to
I put the wish interpreter in the bin directory of cygwin.

#!/cygdrive/c/cgwin64/bin/wish.exe

button .b -text "Hello World" -command exit
pack .b

Now for a message i get invalid command name button.

thx. for any assistance.

lokiofa...@gmail.com

unread,
Nov 3, 2018, 5:53:32 PM11/3/18
to
so I am guessing I need to set some kind of environment variables. otherwise it would know what a button is. I am off to explore what variable or path I need to set.

thx.

lokiofa...@gmail.com

unread,
Nov 3, 2018, 6:13:56 PM11/3/18
to
On Saturday, November 3, 2018 at 5:53:32 PM UTC-4, lokiofa...@gmail.com wrote:
> so I am guessing I need to set some kind of environment variables. otherwise it would know what a button is. I am off to explore what variable or path I need to set.
>
> thx.

I found this:

#!/cygdrive/c/cgwin64/bin/tclsh.exe
load c:/ActiveTcl/lib/tk86t.lib
button .b -text "Hello World" -command exit
pack .b
mister-201@LAPTOP-HT7A13B8 ~/swigwin-3.0.12/proj1
$ ./foo.exe ./mylistbox.tcl

ARRIVING IN MAIN
./mylistbox.tcl
COMMAND CREATED
Error was couldn't load library "c:/ActiveTcl/lib/tk86t.lib": Bad exe format. Possibly a 32/64-bit mismatch.
SCRIPT EVALUATED

which gave that. hmmm...

Andreas Leitgeb

unread,
Nov 3, 2018, 6:17:20 PM11/3/18
to
lokiofa...@gmail.com <lokiofa...@gmail.com> wrote:
> #!/cygdrive/c/cgwin64/bin/sh
>
> exec wish "$0" ${1+"$@"}

This is *part* of a common idiom, but unfortunately another
part is missing, and that is: a comment that ends in a backslash.

A more fruitful preamble would have been:

#!/cygdrive/c/cgwin64/bin/sh
# This backslash lets sh see, but tcl ignore the next line: \
exec wish "$0" ${1+"$@"}

(The text is of course only for humans. only the backslash
is relevant, and #\ on a line before the exec is fine, too)

Because that comment line was missing, tcl also tried to do the
exec, but choked on it's parameters - as they are sh-syntax, not tcl.

As for why cygwin's "wish" doesn't know "button" surprises me,
but maybe it still needs this line (somewhere below the exec):

package require Tk

lokiofa...@gmail.com

unread,
Nov 3, 2018, 7:07:41 PM11/3/18
to
Hi Andreas-

I figured it out. It wanted me to pass in the name of the script. LIKE THIS:
Tcl_Obj * script=Tcl_NewStringObj(" exec wish ./mylistbox.tcl",-1);

thx for the cool reply :-)

jim

Ralf Fassel

unread,
Nov 5, 2018, 5:03:47 AM11/5/18
to
* lokiofa...@gmail.com
| I figured it out. It wanted me to pass in the name of the script. LIKE THIS:
| Tcl_Obj * script=Tcl_NewStringObj(" exec wish ./mylistbox.tcl",-1);

Not sure what you want to achieve, but this seems like walking in the
completely wrong direction to me. Instead of having your own .exe and
try to get tcl into it, use regular tclsh/wish and code your extension
as loadable dll.

There should be plenty of advice in the wiki on how to create a loadable
package for Tcl...

If you have your own .exe and want to have TCL in it, you more or less
have to re-invent tclsh/wish and do all the initialization correct to
make it work properly.

HTH & my EUR 0.01
R'
0 new messages