Artifacts Associated With Ticket 218337ffffffffff
Ticket change [a9c1b47b85] (rid 99207) by nobody on 2000-10-26 00:56:24:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 3974 Bug Version: 8.3b2 SubmitDate: '2000-01-04' LastModified: '2000-02-07' Severity: LOW Status: Closed Submitter: shawn ChangedBy: hobbs OS: Windows NT FixedDate: '2000-10-25' ClosedDate: '2000-02-07' Package present produces an error and breaks out of loop - return from script is an error - package is not present - it would be nice if it told something about the state of the interpretor - so it could be used as a test - I'd like it to return zero if it's not in an interactive interpretor - and it would be nicer still - if it were called without any arguments - if it could tell you all the packages currently loaded. much in the same way info loaded - works. What would really be nice is if it were an info packages comnmand - returning a list if no options are used and a version number if a package is specified. script ------------------ # This probably doesn't need to produce an error either catch { package require {} } foreach a " [package names] " { puts $a set c "100.0" set d ''' if ![ package present $a ] { # to match the extra if a bove # catch { package present $a } msg # if [regsub -- not $msg nothing msg ] { foreach b " [package versions $a] " { lappend l " $a $b " puts $l puts " I could load $a here" if { [package vcompare $b $c] == -1 } { if [string equal $a $d ] { package forget $a } } set c $b set d $a package require -exact $a $b } } } } Below is an example of how getting all the packages is done, and whether they have been loaded or not. proc tkConPkgMenu {m app type} { global TKCON # just in case stuff has been added to the auto_path # we have to make sure that the errorInfo doesn't get screwed up tkConEvalAttached { set __tkcon_error $errorInfo catch {package require bogus-package-name} set errorInfo ${__tkcon_error} unset __tkcon_error } $m delete 0 end foreach pkg [tkConEvalAttached [list info loaded {}]] { set loaded([lindex $pkg 1]) [package provide $pkg] } foreach pkg [lremove [tkConEvalAttached {package names}] Tcl] { set version [tkConEvalAttached [list package provide $pkg]] if {[string compare {} $version]} { set loaded($pkg) $version } elseif {![info exists loaded($pkg)]} { set loadable($pkg) [list package require $pkg] } } foreach pkg [tkConEvalAttached {info loaded}] { set pkg [lindex $pkg 1] if {![info exists loaded($pkg)] && ![info exists loadable($pkg)]} { set loadable($pkg) [list load {} $pkg] } } set npkg 0 foreach pkg [lsort -dictionary [array names loadable]] { foreach v [tkConEvalAttached [list package version $pkg]] { set brkcol [expr {([incr npkg]%16)==0}] $m add command -label "Load $pkg ($v)" -command "tkConEvalOther [list $app] $type $loadable($pkg) $v" -columnbreak $brkcol } } if {[info exists loaded] && [info exists loadable]} { $m add separator } foreach pkg [lsort -dictionary [array names loaded]] { $m add command -label "${pkg}$loaded($pkg) Loaded" -state disabled } } -- 02/07/2000 hobbs - foundin initialized to: "obsolete: 8.3b2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "56. LibTomMath"
- title initialized to:
Package present produces an error and breaks out of loop
- type initialized to: "RFE"
Ticket change [6a2fc82c55] (rid 128101) by welch on 2000-10-26 08:20:07:
- closedate changed to: "2000-10-26T01:20:07"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [f575b5d563] (rid 130112) by dgp on 2001-04-06 02:13:43:
- foundin changed to: "None"
- status changed to: "Open"
- subsystem changed to: "None"
Ticket change [5947cf5a1b] (rid 117952) by dgp on 2001-04-06 02:14:08:
- closedate changed to: "2001-04-05T19:14:08"
- closer changed to: "dgp"
- status changed to: "Closed"
- subsystem changed to: "39. Package Manager"