xo::library proc require (public)

 xo::library[i] require [ -package package ] filename

Defined in /var/www/openacs.org/packages/xotcl-core/tcl/04-library-procs.tcl

Use this method to indicate when some other files (from the same package) are needed to be sourced before the current file. This method is useful in cases where the alphabetical loading order is a problem. A typical use-case is a file defining a subclass of another class. In this case, the file defining the subclass will require the definition of the base class.

Switches:
-package (optional)
Parameters:
filename (required)
filename without path and .tcl suffix

Testcases:
No testcase defined.
Source code:
#:log "--loaded nsv_set [self]-loaded [info script] 1"
nsv_set [self]-loaded [info script] 1
set myfile [file tail [info script]]
set dirname [file dirname [info script]]
if {$package eq ""} {
  set otherfile $dirname/$filename.tcl
} else {
  set otherfile $::acs::rootdir/packages/$package/tcl/$filename.tcl
}
set vn [self]
#:log "--exists otherfile $otherfile => [nsv_exists $vn $otherfile]"
if {[nsv_exists $vn $otherfile]} {
  nsv_set $vn $otherfile [lsort -unique [concat [nsv_get $vn $otherfile] [info script]]]
  #:log "--setting nsv_set $vn $otherfile [lsort -unique [concat [nsv_get $vn $otherfile] $myfile]]"
} else {
  nsv_set $vn $otherfile [info script]
  #:log "--setting nsv_set $vn $otherfile $myfile"
}
#:log "--source when not loaded [self]-loaded $otherfile: [nsv_exists [self]-loaded $otherfile]"
#:log "--loaded = [lsort [nsv_array names [self]-loaded]]"

if {![nsv_exists [self]-loaded $otherfile]} {
  :log "--sourcing first $otherfile"
  apm_source $otherfile
  nsv_set [self]-loaded $otherfile 1
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: