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

How to call procs in another file? 1

Status
Not open for further replies.

ypritzker

Programmer
Jun 2, 2004
2
US
I am new to tcl. How do I include other files and call procs from other files?
 
You can "source" another script:
source <scriptname>

After that you can call the proc's in that file.




Bob Rashkin
rrashkin@csc.com
 
you can also use "auto_mkindex"
Code:
auto_mkindex dir pattern pattern ... 
Generates an index suitable for use by auto_load. The command searches dir for all files whose names match any of the pattern arguments (matching is done with the glob command), generates an index of all the Tcl command procedures defined in all the matching files, and stores the index information in a file named tclIndex in dir. If no pattern is given a pattern of *.tcl will be assumed. For example, the command 
auto_mkindex foo *.tcl

will read all the .tcl files in subdirectory foo and generate a new index file foo/tclIndex.

Auto_mkindex parses the Tcl scripts by sourcing them into a slave interpreter and monitoring the proc and namespace commands that are executed. Extensions can use the (undocumented) auto_mkindex_parser package to register other commands that can contribute to the auto_load index. You will have to read through auto.tcl to see how this works.

This will create a list of where various commands (procs) are. In the script in which you want to use them, you must have a line like:
lappend auto_path <directory where index was created>

Bob Rashkin
rrashkin@csc.com
 
Thank you very much for the tip. I am actually writing jacl scripts for WebSphere administration. I have different variables sets for different environments. So my script is the same, but I am including different values of the variables set into the jacl file. I think I can not use auto_mkindex for that but I successfully used source <variables_filename>. The only question I have how would I use the filename that is in the different directory?
Thanks
 
like: "source <path><filename>"?

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top