Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TK WISH Question

Status
Not open for further replies.

trtcl

Programmer
Joined
Feb 13, 2009
Messages
3
Location
CA
Hi,
I use tcl on unix at work (never used tk) but wanted to do some other projects at home, and i use mac
and since mac has tcl/tk built-in I can run my tcl programs from the mac terminal.

My question is,

when I do the fallowing in my terminal window

% wish
% button .hello -text "my name is trtcl"
.hello
% pack .hello

a window pops up with "my name is trtcl"


but when i insert the fallowing lines in a .tcl file and run it I get the fallowing error message "invalid command name "label"

#!/bin/sh
exec wish "$0" "$@"
label .hello -text "my name is trtcl"
pack .hello

So what is the correct way to have the tk lines in a file ? or what I am doing wrong ?


Thanks in advance


 
Hi

trtcl said:
what I am doing wrong ?
You missed the comment.

[tt]exec[/tt] will run [tt]wish[/tt] passing the same file to it. But [tt]exec[/tt] is a shell built-in, not available in Tcl/Tk.

But both [tt]tclsh[/tt] and [tt]wish[/tt] interpret backslash ( \ ) at the end of line as line continuation even in comments. So, putting a comment with line continuation immediately before the [tt]exec[/tt] line will make it a comment in Tcl/Tk, but leaves it visible for the shell.
Code:
#!/bin/sh
[highlight]# \[/highlight]
exec wish "$0" "$@"
label .hello -text "my name is trtcl"
pack .hello

Feherke.
 
Hi thanks for your reply,

I changed it as you suggested but I still have the same error msg.

% source tktest.tcl
invalid command name "label"


and my tktest.tcl is as fallows;


#!/bin/sh
# \
exec wish "$0" "$@"
label .hello -text "my name is trtcl"
pack .hello
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top