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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I pass parameters when I souce a file?

Status
Not open for further replies.

hcchin0709

Programmer
Aug 21, 2003
1
0
0
US
I like to pass variables taking from front-end TK-GUI to another tcl script file via "source" command, can anyone help me? Thanks!!

Jim Chin

 
You can't.

From the source page of the Tcl manual:
This command takes the contents of the specified file or resource and passes it to the Tcl interpreter as a text script. The return value from source is the return value of the last command executed in the script. If an error occurs in evaluating the contents of the script then the source command will return that error. If a return command is invoked from within the script then the remainder of the file will be skipped and the source command will return normally with the result from the return command.

But you can set global or namespace variables before sourcing and reference these variables inside the sourced script.

HTH

ulis
 
I just saw your posting. Here is one way you can pass parameters to .tcl file.

tclsh x.tcl para1 para2 para3.

This works. THe only thing is that the x.tcl now runs in a different shell.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top