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

Beginner ?: How to know actual path to imported package.?

Status
Not open for further replies.

eewah

Programmer
Mar 10, 2006
35
MY
Lets say I have a script that require MYLIB:
Code:
package require MYLIB

Is there any command that I can use to locate actual path to the MYLIB package which is being required?

Thanks....!
 
From the Tcl manual:
info loaded ?interp?
Returns a list describing all of the packages that have been loaded into interp with the load command. Each list element is a sub-list with two elements consisting of the name of the file from which the package was loaded and the name of the package. For statically-loaded packages the file name will be an empty string. If interp is omitted then information is returned for all packages loaded in any interpreter in the process. To get a list of just the packages in the current interpreter, specify an empty string for the interp argument.


So:
Code:
  package require Tk
  # package name
  set searched Tk
  # get searched item from the list
  foreach item [info loaded {}] \
  {
    foreach {file package} $item break
    if {$package eq $searched} { break }
  }
  
  puts $file

More info at:
HTH

ulis


HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top