1 wm title . "IrTcl Client"
12 wm title $w "Debug Window"
14 frame $w.top -relief raised -border 1
15 frame $w.bot -relief raised -border 1
16 pack $w.top -side top -fill both -expand yes
17 pack $w.bot -fill both
18 scrollbar $w.top.s -command [list $w.top.t yview]
19 text $w.top.t -width 60 -height 10 -wrap word -relief flat -borderwidth 0 \
20 -font fixed -yscroll [list $w.top.s set]
21 pack $w.top.s -side right -fill y
22 pack $w.top.t -expand yes -fill both -expand y
27 # Procedure configure-enable-e {w n}
29 # n menu entry number (0 is first entry)
31 proc configure-enable-e {w n} {
32 $w entryconfigure $n -state normal
35 # Procedure configure-disable-e {w n}
37 # n menu entry number (0 is first entry)
39 proc configure-disable-e {w n} {
40 $w entryconfigure $n -state disabled
42 set noFocus [list -takefocus 0]
45 # Define dummy clock function if it is not there.
46 if {[catch {clock seconds}]} {
52 # Define libdir to the IrTcl configuration directory.
53 # In the line below LIBDIR will be modified during 'make install'.
56 # If the bitmaps sub directory is present with a bitmap we assume
57 # the client is run from the source directory in which case we
58 # set libdir the current directory.
59 if {[file readable [file join bitmaps book2]]} {
63 # Make a final check to see if libdir was set ok.
64 if {! [file readable [file join $libdir bitmaps book2]]} {
65 puts "Cannot locate system files in ${libdir}. You must either run this"
66 puts "program from the source directory root of ir-tcl or you must assure"
67 puts "that it is installed - normally in /usr/local/lib/irtcl"
71 # Initialize a lot of globals.
76 set profile(Default,description) {}
77 set profile(Default,host) {}
78 set profile(Default,port) 210
79 set profile(Default,authentication) {}
80 set profile(Default,maximumRecordSize) 50000
81 set profile(Default,preferredMessageSize) 30000
82 set profile(Default,comstack) tcpip
83 set profile(Default,namedResultSets) 1
84 set profile(Default,queryRPN) 1
85 set profile(Default,queryCCL) 0
86 set profile(Default,protocol) Z39
87 set profile(Default,windowNumber) 1
88 set profile(Default,largeSetLowerBound) 2
89 set profile(Default,smallSetUpperBound) 0
90 set profile(Default,mediumSetPresentNumber) 0
91 set profile(Default,presentChunk) 4
92 set profile(Default,timeDefine) {}
93 set profile(Default,timeLastInit) {}
94 set profile(Default,timeLastExplain) {}
95 set profile(Default,targetInfoName) {}
96 set profile(Default,recentNews) {}
97 set profile(Default,maxResultSets) {}
98 set profile(Default,maxResultSize) {}
99 set profile(Default,maxTerms) {}
100 set profile(Default,multipleDatabases) 0
101 set profile(Default,welcomeMessage) {}
104 set currentDb Default
105 set settingsChanged 0
113 set recordSyntax None
114 set elementSetNames None
119 set queryTypes {Simple}
120 set queryButtons { { {I 0} {I 1} {I 2} } }
121 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
122 {Subject {1=21}} {Any {1=1016}} } }
129 set syntaxList {None sep USMARC UNIMARC UKMARC DANMARC FINMARC NORMARC PICAMARC sep SUTRS sep GRS1}
132 set font(bb,normal) {Helvetica 24}
133 set font(bb,bold) {Helvetica 24 bold}
134 set font(b,normal) {Helvetica 24}
135 set font(b,bold) {Helvetica 18 bold}
136 set font(n,normal) {Helvetica 12}
137 set font(n,bold) {Helvetica 12 bold}
138 set font(s,bold) {Helvetica 10 bold}
139 set font(ss,bold) {Helvetica 8 bold}
141 # Procedure tkerror {err}
143 # Override the Tk error handler function.
149 if {[winfo exists $w]} {
158 label $w.top.b -bitmap error
159 message $w.top.t -aspect 300 -text "Error: $err" -font $font(b,bold)
160 pack $w.top.b $w.top.t -side left -padx 10 -pady 10
162 bottom-buttons $w [list {Close} [list destroy $w]] 1
166 # Read tag set file (if present)
167 if {[file readable [file join $libdir tagsets.tcl]]} {
168 source [file join $libdir tagsets.tcl]
171 # Read the global target configuration file.
172 if {[file readable [file join $libdir irtdb.tcl]]} {
173 # source "${libdir}/irtdb.tcl"
174 source [file join $libdir irtdb.tcl]
176 # Read the local target configuration file.
177 if {[file readable "irtdb.tcl"]} {
181 # Read the user configuration file.
182 if {[file readable [file join $libdir .clientrc.tcl]]} {
183 # source "${libdir}/.clientrc.tcl"
184 source [file join $libdir .clientrc.tcl]
189 set queryAutoOld $queryAuto
191 # Convert old format to new format...
192 foreach target [array names profile] {
193 set timedef [clock seconds]
194 if {[string first , $target] == -1} {
195 if {![info exists profile($target,port)]} {
196 foreach n [array names profile Default,*] {
197 set profile($target,[string range $n 8 end]) $profile($n)
199 set profile($target,description) [lindex $profile($target) 0]
200 set profile($target,host) [lindex $profile($target) 1]
201 set profile($target,port) [lindex $profile($target) 2]
202 set profile($target,authentication) [lindex $profile($target) 3]
203 set profile($target,maximumRecordSize) \
204 [lindex $profile($target) 4]
205 set profile($target,preferredMessageSize) \
206 [lindex $profile($target) 5]
207 set profile($target,comstack) [lindex $profile($target) 6]
208 set profile($target,databases) [lindex $profile($target) 7]
209 set profile($target,timeDefine) $timedef
210 set profile($target,windowNumber) 1
212 unset profile($target)
216 # Assign unique ID's to each target's window number
218 foreach n [array names profile *,windowNumber] {
222 set profile(Default,windowNumber) $wno
224 # These globals describe the current query type. They are set to the
226 set queryButtonsFind [lindex $queryButtons 0]
227 set queryInfoFind [lindex $queryInfo 0]
229 # Procedure read-formats
230 # Read all Tcl source files in the subdirectory 'formats'.
231 # The name of each source will correspond to a display format.
232 proc read-formats {} {
233 global displayFormats
237 cd [file join $libdir formats]
238 set formats [glob {*.[tT][cC][lL]}]
240 if {[file readable $f]} {
242 set l [string length $f]
243 set f [string tolower [string range $f 0 [expr $l - 5]]]
244 lappend displayFormats $f
250 # Procedure set-wrap {m}
251 # m boolean wrap mode
252 # Handler to enable/disable text wrap in the main record window
257 .data.record configure -wrap $m
260 # Procedure dputs {m}
261 # m string to be printed
262 # puts utility for debugging.
270 # Procedure apduDump {}
271 # Logs BER dump of last APDU in window if debugMode is true.
277 if {$debugMode == 0} return
280 set offset [lindex $x 1]
281 set length [lindex $x 0]
283 if {![winfo exists $w]} {
287 wm title $w "APDU information"
292 text $w.top.t -font fixed -width 60 -height 12 -wrap word \
293 -relief flat -borderwidth 0 \
294 -yscrollcommand [list $w.top.s set] -background grey85
295 scrollbar $w.top.s -command [list $w.top.t yview]
296 pack $w.top.s -side right -fill y
297 pack $w.top.t -expand yes -fill both
299 bottom-buttons $w [list {Close} [list destroy $w]] 0
301 $w.top.t insert end "Length: ${length}\n"
303 $w.top.t insert end "Offset: ${offset}\n"
305 $w.top.t insert end [lindex $x 2]
306 $w.top.t insert end "---------------------------------\n"
310 # Procedure set-display-format {f}
312 # Reformats main record window to use display format given by f
313 proc set-display-format {f} {
314 global displayFormat setNo busy
321 .bot.a.status configure -text "Reformatting"
324 add-title-lines -1 10000 1
327 # Procedure initBindings
328 # Disables various default bindings for Text and Listbox widgets.
329 proc initBindings {} {
332 foreach e [bind Text] {
333 set TextBinding($e) [bind Text $e]
337 bind $w <B1-Motion> {}
338 bind $w <Shift-B1-Motion> {}
343 # Procedure TextEditable
344 # Apply "standard" events to a text widget. It should be editable now.
345 proc TextEditable {w} {
348 foreach e [array names TextBinding] {
349 bind $w $e $TextBinding($e)
353 # Procedure destroyGW {w}
355 # Saves geometry of widget w in windowGeometry array. This
356 # Procedure is used to save current geometry of a window before
358 # See also topLevelG.
360 global windowGeometry
361 catch {set windowGeometry($w) [wm geometry $w]}
364 # Procedure topLevelG
366 # Makes a new top level widget named w; sets geometry of window if it
367 # exists in windowGeometry array. The destroyGW procedure is set
368 # to be called when the Destroy event occurs.
370 global windowGeometry
373 if {[info exists windowGeometry($w)]} {
374 set g $windowGeometry($w)
379 bind $w <Destroy> [list destroyGW $w]
382 # Procedure top-down-window {w}
383 # w window (possibly top level)
384 # Makes two frames inside w called top and bot.
385 proc top-down-window {w} {
386 frame $w.top -relief raised -border 1
387 frame $w.bot -relief raised -border 1
388 pack $w.top -side top -fill both -expand yes
389 pack $w.bot -fill both
392 # Procedure top-down-ok-cancel {w ok-action g}
393 # w top level widget with $w.bot-frame
394 # ok-action ok script
396 # Makes two buttons in the bot frame called Ok and Cancel. The
397 # ok-action is executed if Ok is pressed. If Cancel is activated
398 # The window is destroyed. If g is true a grab is performed on the
399 # window and the procedure waits until the window is destroyed.
400 proc top-down-ok-cancel {w ok-action g} {
401 frame $w.bot.left -relief sunken -border 1
402 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 1 -pady 1
403 button $w.bot.left.ok -width 4 -text {Ok} -command ${ok-action}
404 pack $w.bot.left.ok -expand yes -ipadx 1 -ipady 1 -padx 2 -pady 2
405 button $w.bot.cancel -width 5 -text {Cancel} -command [list destroy $w]
406 pack $w.bot.cancel -side left -expand yes
414 # Procedure bottom-buttons {w buttonList g}
415 # w top level widget with $w.bot-frame
416 # buttonList button specifications
418 # Makes a list of buttons in the $w.bot frame. The buttonList is a list
419 # of button specifications. Each button specification consists of two
420 # items; the first item is button label name; the second item is a script
421 # of be executed when that button is executed. A grab is performed if g
422 # is true and it waits for the window to be destroyed.
423 proc bottom-buttons {w buttonList g} {
425 set l [llength $buttonList]
427 frame $w.bot.$i -relief sunken -border 1
428 pack $w.bot.$i -side left -expand yes -padx 2 -pady 2
429 button $w.bot.$i.ok -text [lindex $buttonList $i] \
430 -command [lindex $buttonList [expr $i + 1]]
431 pack $w.bot.$i.ok -expand yes -padx 2 -pady 2 -side left
435 button $w.bot.$i -text [lindex $buttonList $i] \
436 -command [lindex $buttonList [expr $i + 1]]
437 pack $w.bot.$i -expand yes -padx 2 -pady 2 -side left
447 # Procedure cancel-operation
448 # This handler is invoked when the user wishes to cancel an operation.
449 # If the system is currently busy a "Cancel" will be displayed in the
450 # status area and the cancelFlag is set to true indicating that future
451 # responses from the target should be ignored. The system is no longer
452 # busy when this procedure exists.
453 proc cancel-operation {} {
454 global cancelFlag busy delayRequest
459 show-status Cancel 0 1
463 # Procedure show-target {target base}
464 # target name of target
465 # base name of database
466 # Displays target name and database name in the target status area.
467 proc show-target {target base} {
468 if {![string length $target]} {
469 .bot.a.target configure -text {}
472 if {![string length $base]} {
473 .bot.a.target configure -text "$target"
475 .bot.a.target configure -text "$target - $base"
479 # Procedure show-logo {v1}
481 # This procedure maintains the book logo in the bottom of the screen.
482 # It is invoked only once during initialization of windows, etc., and
483 # by itself. The global 'busy' variable determines whether the logo is
485 proc show-logo {v1} {
493 .bot.logo configure -bitmap @[file join $libdir bitmaps book${v1}]
494 after 140 [list show-logo $v1]
498 .bot.logo configure -bitmap @[file join $libdir bitmaps book1]
507 # Procedure show-status {status b sb}
508 # status status message string
510 # sb search busy indicator
511 # Display status information according to 'status' and sets the global
512 # busy flag 'busy' to b if b is non-empty. If sb is non-empty it indicates
513 # whether service buttons should be enabled or disabled.
514 proc show-status {status b sb} {
515 global busy scanEnable setOffset setMax setNo
517 .bot.a.status configure -text "$status"
519 if {$busy == 0} {set busy 1}
527 .top.service configure -state normal
528 .mid.search configure -state normal
530 .mid.scan configure -state normal
532 configure-disable-e .top.service.m 3
535 configure-disable-e .top.service.m 1
536 } elseif {[z39.$setNo nextResultSetPosition] > 0 &&
537 [z39.$setNo nextResultSetPosition] <= [z39.$setNo resultCount]} {
538 configure-enable-e .top.service.m 1
539 .mid.present configure -state normal
541 configure-disable-e .top.service.m 1
542 .mid.present configure -state disabled
544 if {[winfo exists .scan-window]} {
545 .scan-window.bot.2 configure -state normal
546 .scan-window.bot.4 configure -state normal
549 .top.service configure -state disabled
550 .mid.search configure -state disabled
551 .mid.scan configure -state disabled
552 .mid.present configure -state disabled
554 if {[winfo exists .scan-window]} {
555 .scan-window.bot.2 configure -state disabled
556 .scan-window.bot.4 configure -state disabled
561 # Procedure show-message {msg}
563 # Sets message the bottom of the screen to msg.
564 proc show-message {msg} {
565 .bot.a.message configure -text "$msg"
568 # Procedure insertWithTags {w text args}
570 # text string to be inserted
572 # Inserts text at the insertion point in widget w. The text is tagged
573 # with the tags in args.
574 proc insertWithTags {w text args} {
575 set start [$w index insert]
576 $w insert insert $text
577 foreach tag [$w tag names $start] {
578 $w tag remove $tag $start insert
581 $w tag add $i $start insert
585 # Procedure popup-license and displays LICENSE information.
586 proc popup-license {} {
591 wm title $w "License"
596 text $w.top.t -width 80 -height 10 -wrap word -relief flat -borderwidth 0 \
597 -font fixed -yscrollcommand [list $w.top.s set]
598 scrollbar $w.top.s -command [list $w.top.t yview]
599 pack $w.top.s -side right -fill y
600 pack $w.top.t -expand yes -fill both
602 if {[file readable [file join $libdir LICENSE]]} {
603 set f [open [file join $libdir LICENSE] r]
604 while {[gets $f buf] != -1} {
605 $w.top.t insert end $buf
606 $w.top.t insert end "\n"
610 bottom-buttons $w [list {Close} [list destroy $w]] 1
613 # Procedure about-target
614 # Displays various information about the current target, such
615 # as implementation-name, implementation-id, etc.
616 proc about-target {} {
617 set w .about-target-w
622 wm title $w "About target"
626 frame $w.top.a -relief ridge -border 2
627 frame $w.top.p -relief ridge -border 2
628 pack $w.top.a $w.top.p -side top -fill x
630 label $w.top.a.about -text "About"
631 label $w.top.a.irtcl -text $hostid -font $font(bb,bold)
632 pack $w.top.a.about $w.top.a.irtcl -side top
634 set i [z39 targetImplementationName]
635 label $w.top.p.in -text "Implementation name: $i"
636 set i [z39 targetImplementationId]
637 label $w.top.p.ii -text "Implementation id: $i"
638 set i [z39 targetImplementationVersion]
639 label $w.top.p.iv -text "Implementation version: $i"
641 label $w.top.p.op -text "Protocol options: $i"
642 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
644 bottom-buttons $w [list {Close} [list destroy $w]] 1
647 # Procedure about-origin-logo {n}
649 # Displays book logo in the .about-origin-w widget
650 proc about-origin-logo {n} {
652 set w .about-origin-w
653 if {![winfo exists $w]} {
660 $w.top.a.logo configure -bitmap @[file join $libdir bitmaps book$n]
661 after 140 [list about-origin-logo $n]
664 # Procedure about-origin
665 # Display various information about origin (this client).
666 proc about-origin {} {
667 set w .about-origin-w
668 global libdir font tk_version
670 if {[winfo exists $w]} {
675 wm title $w "About IrTcl"
679 frame $w.top.a -relief ridge -border 2
680 frame $w.top.p -relief ridge -border 2
681 pack $w.top.a $w.top.p -side top -fill x
683 label $w.top.a.irtcl -text "IrTcl" -font $font(bb,bold)
684 label $w.top.a.logo -bitmap @[file join $libdir bitmaps book1]
685 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
688 catch {set i [z39 implementationName]}
689 label $w.top.p.in -text "Implementation name: $i"
690 catch {set i [z39 implementationId]}
691 label $w.top.p.ii -text "Implementation id: $i"
692 catch {set i [z39 implementationVersion]}
693 label $w.top.p.iv -text "Implementation version: $i"
695 label $w.top.p.tk -text "Tk version: $i"
696 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.tk -side top -anchor nw
699 bottom-buttons $w [list {Close} [list destroy $w] \
700 {License} [list popup-license]] 0
703 # Procedure popup-marc {sno no b df}
704 # sno result set number
705 # no record position number
706 # b popup window number
708 # Displays record in set $sno at position $no in window .full-marc$b.
709 # The global variable $popupMarcdf holds the current format method.
710 proc popup-marc {sno no b df} {
711 global font displayFormats popupMarcdf
713 if {[z39.$sno type $no] != "DB"} {
718 while {[winfo exists .full-marc$b]} {
724 if {![winfo exists $w]} {
729 frame $w.top -relief raised -border 1
730 frame $w.bot -relief raised -border 1
731 pack $w.top -side top -fill both -expand yes
732 pack $w.bot -fill both
734 text $w.top.record -width 60 -height 5 -wrap word -relief flat \
735 -borderwidth 0 -font fixed \
736 -yscrollcommand [list $w.top.s set] -background grey85
737 scrollbar $w.top.s -command [list $w.top.record yview]
738 $w.top.record tag configure marc-tag -foreground blue
739 $w.top.record tag configure marc-id -foreground red
740 $w.top.record tag configure marc-data -foreground black
741 $w.top.record tag configure marc-head -font $font(n,bold) \
742 -background black -foreground white
743 $w.top.record tag configure marc-pref -font $font(n,normal) -foreground blue
744 $w.top.record tag configure marc-text -font $font(n,normal) -foreground black
745 $w.top.record tag configure marc-it -font $font(n,normal) -foreground black
747 pack $w.top.s -side right -fill y
748 pack $w.top.record -expand yes -fill both
750 bottom-buttons $w [list \
751 {Close} [list destroy $w] \
755 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m -relief raised
756 irmenu $w.bot.formats.m
757 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3 -side left
759 $w.bot.formats.m delete 0 last
762 foreach f $displayFormats {
763 $w.bot.formats.m add radiobutton -label $f -variable popupMarcdf -value $i \
764 -command [list popup-marc $sno $no $b 0]
767 $w.top.record delete 0.0 end
768 set recordType [z39.$sno recordType $no]
769 wm title $w "$recordType record #$no"
771 $w.bot.2 configure -command [list popup-marc $sno [expr $no-1] $b $df]
772 $w.bot.4 configure -command [list popup-marc $sno [expr $no+1] $b $df]
774 $w.bot.2 configure -state disabled
776 $w.bot.2 configure -state normal
778 if {[z39.$sno type [expr $no+1]] != "DB"} {
779 $w.bot.4 configure -state disabled
781 $w.bot.4 configure -state normal
783 $w.bot.6 configure -command [list popup-marc $sno $no -1 0]
784 set ffunc [lindex $displayFormats $df]
785 set ffunc "display-$ffunc"
787 $ffunc $sno $no $w.top.record 0
790 # Procedure update-target-hotlist {target base}
791 # target current target name
792 # base current database name
793 # Updates the global $hotTargets so that $target and $base are
794 # moved to the front, i.e. they become the number 1 target/base.
795 # The target menu is updated by a call to set-target-hotlist.
796 proc update-target-hotlist {target base} {
799 set olen [llength $hotTargets]
801 foreach e $hotTargets {
802 if {$target == [lindex $e 0] && $base == [lindex $e 1]} {
803 set hotTargets [lreplace $hotTargets $i $i]
808 set hotTargets [linsert $hotTargets 0 [list $target $base]]
809 set-target-hotlist $olen
812 # Procedure delete-target-hotlist {target}
813 # target target to be deleted
814 # Updates the global $hotTargets so that $target is removed.
815 # The target menu is updated by a call to set-target-hotlist.
816 proc delete-target-hotlist {target} {
819 set olen [llength $hotTargets]
821 foreach e $hotTargets {
822 if {$target == [lindex $e 0]} {
823 set hotTargets [lreplace $hotTargets $i $i]
827 set-target-hotlist $olen
830 # Procedure set-target-hotlist {olen}
831 # olen number of hot target entries to be deleted from menu
832 # Updates the target menu with the targets with the first 8 entries
833 # in the $hotTargets global.
834 proc set-target-hotlist {olen} {
838 .top.target.m delete 6 [expr 6+$olen]
841 foreach e $hotTargets {
842 set target [lindex $e 0]
843 set base [lindex $e 1]
844 if {![string length $base]} {
845 .top.target.m add command -label "$i $target" -command \
846 [list reopen-target $target {}]
848 .top.target.m add command -label "$i $target - $base" -command \
849 [list reopen-target $target $base]
858 # Procedure reopen-target {target base}
859 # target target to be opened
860 # base base to be used
861 # Closes connection with current target and opens a new connection
862 # with $target and database $base.
863 proc reopen-target {target base} {
865 open-target $target $base
866 update-target-hotlist $target $base
869 # Procedure define-target-action
870 # Prepares the setup of a new target. The name of the target
871 # is read from the dialog .target-define dialog (procedure
872 # define-target-dialog) and the target definition window is displayed by
873 # a call to protocol-setup.
874 proc define-target-action {} {
877 set target [.target-define.top.target.entry get]
878 if {![string length $target]} {
881 foreach n [array names profile *,host] {
882 if {![string compare $n ${target},host]} {
883 destroy .target-define
888 foreach n [array names profile Default,*] {
889 set profile($target,[string range $n 8 end]) $profile($n)
892 incr profile(Default,windowNumber)
894 protocol-setup $target
895 destroy .target-define
898 # Procedure fail-response {target}
899 # target current target
900 # Error handler (IrTcl failback) that takes care of serious protocol
901 # errors, connection lost, etc.
902 proc fail-response {target} {
905 set c [lindex [z39 failInfo] 0]
906 set m [lindex [z39 failInfo] 1]
907 if {$c == 4 || $c == 5} {
916 # Procedure connect-response {target base}
917 # target current target
918 # base current database
919 # IrTcl connect response handler.
920 proc connect-response {target base} {
921 dputs "connect-response"
922 init-request $target $base
925 # Procedure open-target {target base}
926 # target target to be opened
927 # base database to be used
928 # Opens a new connection with $target/$base.
929 proc open-target {target base} {
930 global profile hostid presentChunk currentDb
933 z39 comstack $profile($target,comstack)
934 z39 protocol $profile($target,protocol)
935 eval z39 idAuthentication $profile($target,authentication)
936 z39 maximumRecordSize $profile($target,maximumRecordSize)
937 z39 preferredMessageSize $profile($target,preferredMessageSize)
938 dputs "maximumRecordSize=[z39 maximumRecordSize]"
939 dputs "preferredMessageSize=[z39 preferredMessageSize]"
940 show-status Connecting 1 0
941 set x $profile($target,largeSetLowerBound)
942 if {![string length $x]} {
945 z39 largeSetLowerBound $x
947 set x $profile($target,smallSetUpperBound)
948 if {![string length $x]} {
951 z39 smallSetUpperBound $x
953 set x $profile($target,mediumSetPresentNumber)
954 if {![string length $x]} {
957 z39 mediumSetPresentNumber $x
959 set presentChunk $profile($target,presentChunk)
960 if {![string length $presentChunk]} {
964 z39 failback [list fail-response $target]
965 z39 callback [list connect-response $target $base]
966 show-target $target $base
969 z39 connect $profile($target,host):$profile($target,port)
973 # tkerror $errorMessage
974 bgerror $errorMessage
975 show-status "Not connected" 0 {}
981 configure-disable-e .top.target.m 0
982 configure-enable-e .top.target.m 1
983 configure-enable-e .top.target.m 2
986 # Procedure close-target
987 # Shuts down the connection with current target.
988 proc close-target {} {
989 global hostid cancelFlag setNo setNoLast currentDb
994 .bot.a.set configure -text ""
996 set currentDb Default
999 show-status {Not connected} 0 0
1000 .top.options.m.query.slist entryconfigure 2 -state disabled
1003 configure-disable-e .top.target.m 1
1004 configure-disable-e .top.target.m 2
1005 .top.rset.m delete 1 last
1006 .top.rset.m add separator
1007 configure-enable-e .top.target.m 0
1010 # Procedure load-set-action
1011 # Loads records from a file. The filename is read from the entry
1012 # .load-set.filename.entry (see function load-set)
1013 proc load-set-action {} {
1017 ir-set z39.$setNoLast z39
1019 set fname [.load-set.top.filename.entry get]
1022 show-status Loading 1 {}
1024 z39.$setNoLast loadFile $fname
1026 set no [z39.$setNoLast numberOfRecordsReturned]
1027 add-title-lines $setNoLast $no 1
1029 set l [format "%-4d %7d" $setNoLast $no]
1030 .top.rset.m add command -label $l \
1031 -command [list add-title-lines $setNoLast 10000 1]
1032 show-status Ready 0 {}
1035 # Procedure load-set
1036 # Dialog that asks for a filename with records to be loaded
1037 # into a result set.
1041 set oldFocus [focus]
1045 frame $w.top.filename
1046 pack $w.top.filename -side top -anchor e -pady 2
1048 entry-fields $w.top {filename} \
1050 {load-set-action} {destroy .load-set}
1052 top-down-ok-cancel $w {load-set-action} 1
1056 # Procedure init-request
1057 # Sends an initialize request to the target. This procedure is called
1058 # when a connect has been established.
1059 proc init-request {target base} {
1066 z39 callback [list init-response $target $base]
1067 show-status Initializing 1 {}
1068 set err [catch {z39 init} errorMessage]
1070 # tkerror $errorMessage
1071 bgerror $errorMessage
1072 show-status Ready 0 {}
1076 # Procedure init-response
1077 # Handles and incoming init-response. The service buttons
1078 # are enabled. The global $scanEnable indicates whether the target
1080 proc init-response {target base} {
1081 global cancelFlag profile scanEnable settingsChanged
1083 dputs {init-response}
1089 if {![z39 initResult]} {
1090 set u [z39 userInformationField]
1092 # tkerror "Connection rejected by target: $u"
1093 bgerror "Connection rejected by target: $u"
1095 z39 failback [list explain-crash $target $base]
1096 explain-check $target [list ready-response $base] $base
1100 # Procedure explain-crash
1101 # Handles target that dies during explain.
1102 proc explain-crash {target base} {
1103 global profile settingsChanged
1105 set profile($target,timeLastInit) [clock seconds]
1106 set settingsChanged 1
1109 open-target $target $base
1112 # Procedure explain-check
1113 # Stub function to check explain. May be overwritten later.
1114 #proc explain-check {target response}
1115 # eval $response [list $target]
1118 # Procedure ready-response
1119 # Called after a target has been initialized and, possibly, explained
1120 proc ready-response {base target} {
1121 global profile settingsChanged scanEnable queryAuto
1123 z39 failback [list fail-response $target]
1124 if {[string length $base]} {
1125 set profile($target,timeLastInit) [clock seconds]
1126 set settingsChanged 1
1128 z39 databaseNames $base
1129 cascade-dblist $target $base
1130 show-target $target $base
1132 if {[lsearch [z39 options] scan] >= 0} {
1137 .data.record delete 1.0 end
1138 set desc [string trim $profile($target,description)]
1139 if {[string length $desc]} {
1140 .data.record insert end "$desc\n\n"
1142 .data.record insert end "$target\n\n"
1144 set data [string trim $profile($target,welcomeMessage)]
1145 if {[string length $data]} {
1146 .data.record insert end "Welcome Message:\n$data\n\n"
1148 set data [string trim $profile($target,recentNews)]
1149 if {[string length $data]} {
1150 .data.record insert end "News:\n$data\n"
1152 ready-response-actions $target $base
1154 show-status Ready 0 1
1157 #proc ready-response-actions {target base}
1158 #This procedure take care of all the actions that should start if connect is succesfull.
1159 proc ready-response-actions {target base} {
1160 global profile queryAuto attributeTypeSelected
1161 configureOptionsSyntax $target $base
1162 if {[info exists profile($target,AttributeDetails,$base,Bib1Use)] && $queryAuto == 1} {
1163 changeQueryButtons $target $base
1164 change-queryInfo $target $base
1166 .top.options.m.query.slist entryconfigure 2 -state normal
1169 .top.options.m.query.slist entryconfigure 2 -state disabled
1171 if {[info exists attributeTypeSelected]} {
1172 global attribute[set attributeTypeSelected]
1173 set attribute$attributeTypeSelected 1
1175 global attributeBib1
1180 # Procedure search-request
1181 # bflag flag to indicate if this procedure calls itself
1182 # Performs a search. If $busy is 1, the search-request is performed
1183 # at a later time (when another response arrives). This procedure
1184 # sets many search-related Z39-settings. The global $setNo is set
1185 # to the result set number (z39.$setNo).
1186 proc search-request {bflag} {
1187 global setNo setNoLast profile hostid busy cancelFlag delayRequest recordSyntax elementSetNames
1191 if {![string length [z39 connect]]} {
1194 dputs "search-request"
1196 if {!$bflag && $busy} {
1197 dputs "busy: search-request ignored"
1202 show-status Searching 1 0
1203 set delayRequest {search-request 1}
1208 set query [index-query]
1209 if {![string length $query]} {
1213 set setNo $setNoLast
1214 ir-set z39.$setNo z39
1216 if {$profile($target,namedResultSets)} {
1217 z39.$setNo setName $setNo
1218 dputs "setName=${setNo}"
1220 z39.$setNo setName default
1221 dputs "setName=default"
1223 if {$profile($target,queryRPN)} {
1224 z39.$setNo queryType rpn
1225 } elseif {$profile($target,queryCCL)} {
1226 z39.$setNo queryType ccl
1230 if {![string compare $recordSyntax None]} {
1231 z39.$setNo preferredRecordSyntax {}
1233 z39.$setNo preferredRecordSyntax $recordSyntax
1235 if {![string compare $elementSetNames None]} {
1236 z39.$setNo elementSetNames {}
1237 z39.$setNo smallSetElementSetNames {}
1238 z39.$setNo mediumSetElementSetNames {}
1240 z39.$setNo elementSetNames $elementSetNames
1241 z39.$setNo smallSetElementSetNames $elementSetNames
1242 z39.$setNo mediumSetElementSetNames $elementSetNames
1244 z39 callback {search-response}
1245 z39.$setNo search $query
1246 show-status Searching 1 0
1249 # Procedure scan-copy {y entry}
1250 # y y-position of mouse pointer
1251 # entry a search entry in the top
1252 # Copies the term in the list nearest $y to the query entry specified
1254 proc scan-copy {y entry} {
1256 set no [$w.top.list nearest $y]
1258 .lines.$entry.e delete 0 end
1259 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
1262 # Procedure scan-request
1263 # Performs a scan on term "0" with the current attributes in entry
1264 # specified by the global $curIndexEntry.
1265 proc scan-request {} {
1268 global profile hostid scanView scanTerm curIndexEntry queryButtonsFind \
1269 queryInfoFind cancelFlag delayRequest
1271 dputs "scan-request"
1274 show-status Scanning 1 0
1275 set delayRequest scan-request
1282 set b [lindex $queryButtonsFind $curIndexEntry]
1284 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
1285 set attr "@attr $a $attr"
1287 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
1288 ir-scan z39.scan z39
1290 if {![winfo exists $w]} {
1297 entry $w.top.entry -relief sunken
1298 pack $w.top.entry -fill x -padx 4 -pady 2
1299 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
1300 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] -font fixed
1301 scrollbar $w.top.scroll -orient vertical -border 1
1302 pack $w.top.list -side left -fill both -expand yes
1303 pack $w.top.scroll -side right -fill y
1304 $w.top.scroll config -command [list $w.top.list yview]
1306 bottom-buttons $w [list {Close} [list destroy $w] \
1307 {Up} [list scan-up $attr] \
1308 {Down} [list scan-down $attr]] 0
1309 bind $w.top.list <Up> [list scan-up $attr]
1310 bind $w.top.list <Down> [list scan-down $attr]
1313 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
1314 wm title $w "Scan $title"
1316 z39 callback [list scan-response $attr 0 35]
1317 z39.scan numberOfTermsRequested 5
1318 z39.scan preferredPositionInResponse 1
1319 z39.scan scan "${attr} 0"
1321 show-status Scanning 1 0
1324 # Procedure scan-term-h {attr}
1325 # attr attribute specification
1326 # This procedure is called whenever a key is released in the entry in the
1327 # scan window (.scan-window). A scan is then initiated with the new contents
1328 # of the entry as the starting term.
1329 proc scan-term-h {attr} {
1330 global busy scanTerm
1336 set nScanTerm [$w.top.entry get]
1337 if {$nScanTerm == $scanTerm} {
1340 set scanTerm $nScanTerm
1341 z39 callback [list scan-response $attr 0 35]
1342 z39.scan numberOfTermsRequested 5
1343 z39.scan preferredPositionInResponse 1
1344 dputs "${attr} \{${scanTerm}\}"
1345 if {![string length $scanTerm]} {
1346 z39.scan scan "${attr} 0"
1348 z39.scan scan "${attr} \{${scanTerm}\}"
1350 show-status Scanning 1 0
1353 # Procedure scan-response {attr start toget}
1354 # attr attribute specification
1355 # start position of first term in the response
1356 # toget number of total terms to get
1357 # This procedure handles all scan-responses. $start specifies the list
1358 # entry number of the first incoming term. The $toget indicates the total
1359 # number of terms to be retrieved from the target. The $toget may be
1360 # negative in which case, scan is performed 'backwards' (- $toget is
1361 # the total number of terms in this case). This procedure usually calls
1362 # itself several times in order to get small scan-term-list chunks.
1363 proc scan-response {attr start toget} {
1364 global cancelFlag delayRequest scanTerm scanView
1367 dputs "In scan-response"
1369 set m [z39.scan numberOfEntriesReturned]
1375 if {![winfo exists .scan-window]} {
1378 dputs "Handling cancel"
1379 if {$delayRequest != ""} {
1384 show-status Ready 0 1
1387 set nScanTerm [$w.top.entry get]
1388 if {$nScanTerm != $scanTerm} {
1389 z39 callback [list scan-response $attr 0 35]
1390 z39.scan numberOfTermsRequested 5
1391 z39.scan preferredPositionInResponse 1
1392 set scanTerm $nScanTerm
1393 dputs "${attr} \{${scanTerm}\}"
1394 if {![string length $scanTerm]} {
1395 z39.scan scan "${attr} 0"
1397 z39.scan scan "${attr} \{${scanTerm}\}"
1399 show-status Scanning 1 0
1402 set status [z39.scan scanStatus]
1404 # tkerror "Scan fail"
1406 show-status Ready 0 1
1411 for {set i 0} {$i < $m} {incr i} {
1412 set term [lindex [z39.scan scanLine $i] 1]
1413 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1414 $w.top.list insert $i "$nostr $term"
1417 $w.top.list yview $scanView
1419 $w.top.list delete $start end
1420 for {set i 0} {$i < $m} {incr i} {
1421 set term [lindex [z39.scan scanLine $i] 1]
1422 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1423 $w.top.list insert end "$nostr $term"
1427 dputs "Handling cancel"
1429 if {$delayRequest != ""} {
1435 if {$toget > 0 && $m > 1 && $m < $toget} {
1436 set ntoget [expr $toget - $m + 1]
1437 dputs ntoget=$ntoget
1438 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1440 dputs "down continue: $q"
1442 z39.scan numberOfTermsRequested 10
1444 z39.scan numberOfTermsRequested $ntoget
1446 z39.scan preferredPositionInResponse 1
1447 dputs "${attr} \{$q\}"
1448 z39.scan scan "${attr} \{$q\}"
1451 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1452 set ntoget [expr - $toget - $m]
1453 dputs ntoget=$ntoget
1454 z39 callback [list scan-response $attr 0 -$ntoget]
1455 set q [string range [$w.top.list get 0] 8 end]
1456 dputs "up continue: $q"
1458 z39.scan numberOfTermsRequested 10
1459 z39.scan preferredPositionInResponse 11
1461 z39.scan numberOfTermsRequested $ntoget
1462 z39.scan preferredPositionInResponse [incr ntoget]
1464 dputs "${attr} \{$q\}"
1465 z39.scan scan "${attr} \{$q\}"
1468 show-status Ready 0 1
1471 # Procedure scan-down {attr}
1472 # attr attribute specification
1473 # This procedure is called when the user hits the Down button the scan
1474 # window. A new scan is initiated with a positive $toget passed to the
1475 # scan-response handler.
1476 proc scan-down {attr} {
1477 global scanView cancelFlag delayRequest
1482 show-status {Scanning down} 1 0
1483 set delayRequest [list scan-down $attr]
1489 set scanView [expr $scanView + 5]
1490 set s [$w.top.list size]
1491 if {$scanView > $s} {
1492 z39 callback [list scan-response $attr [expr $s - 1] 25]
1493 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1495 z39.scan numberOfTermsRequested 10
1496 z39.scan preferredPositionInResponse 1
1497 show-status Scanning 1 0
1498 dputs "${attr} \{$q\}"
1499 z39.scan scan "${attr} \{$q\}"
1502 $w.top.list yview $scanView
1505 # Procedure scan-up {attr}
1506 # attr attribute specification
1507 # This procedure is called when the user hits the Up button the scan
1508 # window. A new scan is initiated with a negative $toget passed to the
1509 # scan-response handler.
1510 proc scan-up {attr} {
1511 global scanView cancelFlag delayRequest
1516 show-status Scanning 1 0
1517 set delayRequest [list scan-up $attr]
1523 set scanView [expr $scanView - 5]
1524 if {$scanView < 0} {
1525 z39 callback [list scan-response $attr 0 -25]
1526 set q [string range [$w.top.list get 0] 8 end]
1528 z39.scan numberOfTermsRequested 10
1529 z39.scan preferredPositionInResponse 11
1530 show-status Scanning 1 0
1531 z39.scan scan "${attr} \{$q\}"
1534 $w.top.list yview $scanView
1537 # Procedure search-response
1538 # This procedure handles search-responses. If the search is successful
1539 # this procedure will try to retrieve a total of 20 records from the target;
1540 # however not more than $presentChunk records at a time. This procedure
1541 # affects the following globals:
1542 # $setOffset current record position offset
1543 # $setMax total number of records to be retrieved
1544 proc search-response {} {
1545 global setNo setOffset setMax cancelFlag busy delayRequest presentChunk
1548 dputs "In search-response"
1550 dputs "Handling cancel"
1552 if {$delayRequest != ""} {
1560 set setMax [z39.$setNo resultCount]
1561 show-status Ready 0 1
1562 set status [z39.$setNo responseStatus]
1563 if {![string compare [lindex $status 0] NSD]} {
1564 z39.$setNo nextResultSetPosition 0
1565 set code [lindex $status 1]
1566 set msg [lindex $status 2]
1567 set addinfo [lindex $status 3]
1568 # tkerror "NSD$code: $msg: $addinfo"
1569 bgerror "NSD$code: $msg: $addinfo"
1572 show-message "${setMax} hits"
1577 show-status Ready 0 1
1578 set l [format "%-4d %7d" $setNo $setMax]
1579 .top.rset.m add command -label $l -command [list recall-set $setNo]
1583 set no [z39.$setNo numberOfRecordsReturned]
1584 dputs "Returned $no records, setOffset $setOffset"
1585 add-title-lines $setNo $no $setOffset
1586 set setOffset [expr $setOffset + $no]
1588 set toGet [expr $setMax - $setOffset + 1]
1590 if {$setOffset == 1} {
1592 } elseif {$toGet > $presentChunk} {
1593 set toGet $presentChunk
1595 z39 callback {present-response}
1596 z39.$setNo present $setOffset $toGet
1597 show-status Retrieving 1 0
1601 # Procedure present-more {number}
1602 # number number of records to be retrieved
1603 # This procedure starts a present-request. The $number variable indicates
1604 # the total number of records to be retrieved. The global $presentChunk
1605 # specifies the number of records to be retrieved at a time. If $number
1606 # is the empty string all remaining records in the result set are
1608 proc present-more {number} {
1609 global setNo setOffset setMax busy cancelFlag delayRequest presentChunk
1611 dputs "present-more"
1613 show-status Retrieving 1 0
1614 set delayRequest "present-more $number"
1620 dputs "setNo=$setNo"
1623 set setOffset [z39.$setNo nextResultSetPosition]
1624 dputs "setOffest=${setOffset}"
1625 dputs "setNo=${setNo}"
1626 set max [z39.$setNo resultCount]
1627 if {$max < $setOffset} {
1629 dputs "setOffset=$setOffset"
1630 show-status Ready 0 1
1633 if {![string length $number]} {
1637 if {$setMax > $max} {
1641 z39 callback {present-response}
1643 set toGet [expr $setMax - $setOffset + 1]
1647 if {$toGet > $presentChunk} {
1648 set toGet $presentChunk
1650 z39.$setNo present $setOffset $toGet
1651 show-status Retrieving 1 0
1654 # Procedure init-title-lines
1655 # Utility that cleans the main record window.
1656 proc init-title-lines {} {
1657 .data.record delete 1.0 end
1660 # Procedure recall-set {setno}
1661 # setno Set number to recall
1662 proc recall-set {setno} {
1663 add-title-lines $setno 10000 1
1666 # Procedure add-title-lines {setno no offset}
1668 # no Number of records
1669 # offset Starting offset
1670 # This procedure displays the records $offset .. $offset+$no-1 in result
1671 # set $setno in the main record window by using the display format in the
1672 # global $displayFormat
1673 proc add-title-lines {setno no offset} {
1674 global displayFormats displayFormat setNo busy
1676 dputs "add-title-lines offset=${offset} no=${no}"
1683 .bot.a.set configure -text $setno
1684 .data.record delete 1.0 end
1686 set ffunc [lindex $displayFormats $displayFormat]
1687 dputs "ffunc=$ffunc"
1688 set ffunc "display-$ffunc"
1689 for {set i 0} {$i < $no} {incr i} {
1690 set o [expr $i + $offset]
1691 set type [z39.$setno type $o]
1692 if {![string length $type]} {
1693 dputs "no more at $o"
1696 .data.record tag bind r$o <Any-Enter> {}
1697 .data.record tag bind r$o <Any-Leave> {}
1698 set insert0 [.data.record index insert]
1699 $ffunc $setno $o .data.record 1
1700 .data.record tag add r$o $insert0 insert
1701 .data.record tag bind r$o <1> [list popup-marc $setno $o 0 0]
1705 show-status Ready 0 1
1709 # Procedure present-response
1710 # Present-response handler. The incoming records are displayed and a new
1711 # present request is performed until all records ($setMax) is returned
1713 proc present-response {} {
1714 global setNo setOffset setMax cancelFlag delayRequest presentChunk
1716 dputs "In present-response"
1718 set no [z39.$setNo numberOfRecordsReturned]
1719 dputs "Returned $no records, setOffset $setOffset"
1720 add-title-lines $setNo $no $setOffset
1721 set setOffset [expr $setOffset + $no]
1723 dputs "Handling cancel"
1725 if {$delayRequest != ""} {
1730 set status [z39.$setNo responseStatus]
1731 if {![string compare [lindex $status 0] NSD]} {
1732 show-status Ready 0 1
1733 set code [lindex $status 1]
1734 set msg [lindex $status 2]
1735 set addinfo [lindex $status 3]
1736 # tkerror "NSD$code: $msg: $addinfo"
1737 bgerror "NSD$code: $msg: $addinfo"
1740 if {$no > 0 && $setOffset <= $setMax} {
1741 dputs "present-request from ${setOffset}"
1742 set toGet [expr $setMax - $setOffset + 1]
1743 if {$toGet > $presentChunk} {
1744 set toGet $presentChunk
1746 z39.$setNo present $setOffset $toGet
1748 show-status Ready 0 1
1752 # Procedure left-cursor {w}
1754 # Tries to move the cursor left in entry window $w
1755 proc left-cursor {w} {
1756 set i [$w index insert]
1764 # Procedure right-cursor {w}
1766 # Tries to move the cursor right in entry window $w
1767 proc right-cursor {w} {
1768 set i [$w index insert]
1774 # Procedure bind-fields {list returnAction escapeAction}
1775 # list list of entry widgets
1776 # returnAction return script
1777 # escapeAction escape script
1778 # Each widget in list are assigned bindings for <Tab>, <Left>, <Right>,
1779 # <Return> and <Escape>.
1780 proc bind-fields {list returnAction escapeAction} {
1781 set max [expr [llength $list]-1]
1782 for {set i 0} {$i < $max} {incr i} {
1783 bind [lindex $list $i] <Return> $returnAction
1784 bind [lindex $list $i] <Escape> $escapeAction
1785 bind [lindex $list $i] <Tab> [list focus [lindex $list [expr $i+1]]]
1786 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1787 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1789 bind [lindex $list $i] <Return> $returnAction
1790 bind [lindex $list $i] <Escape> $escapeAction
1791 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1792 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1793 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1794 focus [lindex $list 0]
1797 # Procedure entry-fields {parent list tlist returnAction escapeAction}
1798 # list list of frame widgets
1799 # tlist list of text to be used as lead of each entry
1800 # returnAction return script
1801 # escapeAction escape script
1802 # Makes label and entry widgets in each widget in $list.
1803 proc entry-fields {parent list tlist returnAction escapeAction} {
1806 foreach field $list {
1807 set label ${parent}.${field}.label
1808 set entry ${parent}.${field}.entry
1809 label $label -text [lindex $tlist $i] -anchor e
1810 entry $entry -width 32 -relief sunken
1811 pack $label -side left
1812 pack $entry -side right
1813 lappend alist $entry
1816 bind-fields $alist $returnAction $escapeAction
1819 # Procedure define-target-dialog
1820 # Dialog that asks for new target to be defined.
1821 proc define-target-dialog {} {
1822 set w .target-define
1828 pack $w.top.target -side top -anchor e -pady 2
1829 entry-fields $w.top {target} {{Target:}} \
1830 {define-target-action} {destroy .target-define}
1831 top-down-ok-cancel $w {define-target-action} 1
1834 # Procedure place-force {window parent}
1835 # window new top level widget
1836 # parent parent widget used as base
1837 # Sets geometry of $window relative to $parent window.
1838 proc place-force {window parent} {
1839 set g [wm geometry $parent]
1840 set p1 [string first + $g]
1841 set p2 [string last + $g]
1842 set x [expr 40+[string range $g [expr {$p1 + 1}] [expr {$p2 -1}]]]
1843 set y [expr 60+[string range $g [expr {$p2 + 1}] end]]
1844 wm geometry $window +${x}+${y}
1847 # Procedure add-database-action {target w}
1848 # target target to be defined
1849 # w top level widget for the target definition
1850 # Adds the contents of .database-select.top.database.entry to list of
1852 proc add-database-action {target w} {
1855 $w.top.databases.list insert end [.database-select.top.database.entry get]
1856 destroy .database-select
1859 # Procedure add-database {target wp}
1860 # target target to be defined
1861 # wp top level widget for the target definition
1862 # Makes a dialog in which the user enters new database
1863 proc add-database {target wp} {
1866 set w .database-select
1868 set oldFocus [focus]
1871 frame $w.top.database
1872 pack $w.top.database -side top -anchor e -pady 2
1873 entry-fields $w.top {database} {{Database to add:}} \
1874 [list add-database-action $target $wp] {destroy .database-select}
1876 top-down-ok-cancel $w [list add-database-action $target $wp] 1
1881 # Procedure delete-database {target w}
1882 # target target to be defined
1883 # w top level widget for the target definition
1884 # Asks the user if he/she really wishes to delete a database and removes
1885 # the database from the database-list if requested.
1886 proc delete-database {target w} {
1890 foreach i [$w.top.databases.list curselection] {
1891 set b [$w.top.databases.list get $i]
1894 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1896 foreach i [lsort -decreasing \
1897 [$w.top.databases.list curselection]] {
1898 $w.top.databases.list delete $i
1903 # Procedure advanced-setup {target b}
1904 # target target to be defined
1905 # b window number of target top level
1906 # Makes a dialog in which the user may modify/view advanced settings
1907 # of a target definition (profile).
1908 proc advanced-setup {target b} {
1909 global profile profileS
1911 set w .advanced-setup-$b
1913 wm title $w "Advanced setup $target"
1915 if {![string length $target]} {
1920 frame $w.top.largeSetLowerBound
1921 frame $w.top.smallSetUpperBound
1922 frame $w.top.mediumSetPresentNumber
1923 frame $w.top.presentChunk
1924 frame $w.top.maximumRecordSize
1925 frame $w.top.preferredMessageSize
1927 pack $w.top.largeSetLowerBound $w.top.smallSetUpperBound \
1928 $w.top.mediumSetPresentNumber $w.top.presentChunk \
1929 $w.top.maximumRecordSize $w.top.preferredMessageSize \
1930 -side top -anchor e -pady 2
1932 entry-fields $w.top {largeSetLowerBound smallSetUpperBound \
1933 mediumSetPresentNumber presentChunk maximumRecordSize \
1934 preferredMessageSize} \
1935 {{Large Set Lower Bound:} {Small Set Upper Bound:} \
1936 {Medium Set Present Number:} {Present Chunk:} \
1937 {Maximum Record Size:} {Preferred Message Size:}} \
1938 [list advanced-setup-action $target $b] [list destroy $w]
1940 $w.top.largeSetLowerBound.entry configure -textvariable \
1941 profileS($target,largeSetLowerBound)
1942 $w.top.smallSetUpperBound.entry configure -textvariable \
1943 profileS($target,smallSetUpperBound)
1944 $w.top.mediumSetPresentNumber.entry configure -textvariable \
1945 profileS($target,mediumSetPresentNumber)
1946 $w.top.presentChunk.entry configure -textvariable \
1947 profileS($target,presentChunk)
1948 $w.top.maximumRecordSize.entry configure -textvariable \
1949 profileS($target,maximumRecordSize)
1950 $w.top.preferredMessageSize.entry configure -textvariable \
1951 profileS($target,preferredMessageSize)
1953 bottom-buttons $w [list {Ok} [list advanced-setup-action $target $b] \
1954 {Cancel} [list destroy $w]] 0
1957 # Procedure advanced-setup-action {target b}
1958 # target target to be defined
1959 # b window number of target top level
1960 # This procedure is called when the user hits Ok in the advanced target
1961 # setup dialog. The temporary result is stored in the $profileS - array.
1962 proc advanced-setup-action {target b} {
1963 set w .advanced-setup-$b
1966 set profileS($target,LSLB) [$w.top.largeSetLowerBound.entry get]
1967 set profileS($target,SSUB) [$w.top.smallSetUpperBound.entry get]
1968 set profileS($target,MSPN) [$w.top.mediumSetPresentNumber.entry get]
1969 set profileS($target,presentChunk) [$w.top.presentChunk.entry get]
1970 set profileS($target,MRS) [$w.top.maximumRecordSize.entry get]
1971 set profileS($target,PMS) [$w.top.preferredMessageSize.entry get]
1973 dputs "advanced-setup-action"
1977 # Procedure database-select-action
1978 # Called when the user commits a database select change. See procedure
1980 proc database-select-action {} {
1981 set w .database-select.top
1983 foreach indx [$w.databases.list curselection] {
1984 lappend b [$w.databases.list get $indx]
1987 z39 databaseNames $b
1989 destroy .database-select
1992 # Procedure database-select
1993 # Makes a dialog in which the user may select a database
1994 proc database-select {} {
1995 set w .database-select
1996 global profile hostid
1999 set oldFocus [focus]
2003 frame $w.top.databases -relief ridge -border 2
2004 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
2006 label $w.top.databases.label -text "List"
2007 listbox $w.top.databases.list -width 20 -height 6 \
2008 -yscrollcommand "$w.top.databases.scroll set"
2009 scrollbar $w.top.databases.scroll -orient vertical -border 1
2010 pack $w.top.databases.label -side top -fill x -padx 2 -pady 2
2011 pack $w.top.databases.list -side left -fill both -expand yes -padx 2 -pady 2
2012 pack $w.top.databases.scroll -side right -fill y -padx 2 -pady 2
2013 $w.top.databases.scroll config -command "$w.top.databases.list yview"
2015 foreach b $profile($hostid,databases) {
2016 $w.top.databases.list insert end $b
2018 top-down-ok-cancel $w {database-select-action} 1
2022 # Procedure cascase-dblist-select
2023 proc cascade-dblist-select {target db} {
2024 show-target $target $db
2025 z39 databaseNames $db
2026 ready-response-actions $target $db
2029 # Procedure cascade-dblist
2030 # Makes the Service/database list with proper databases for the target
2031 proc cascade-dblist {target base} {
2034 set w .top.service.m.dblist
2036 if {[info exists profile($target,databases)]} {
2037 foreach db $profile($target,databases) {
2038 $w add command -label $db \
2039 -command [list cascade-dblist-select $target $db]
2044 # Procedure cascade-target-list
2045 # Makes all target/databases available in the Target|Connect
2046 # menu as well as all targets in the Target|Setup menu.
2047 # This procedure is called whenever target definitions occur.
2048 proc cascade-target-list {} {
2051 foreach sub [winfo children .top.target.m.clist] {
2054 .top.target.m.clist delete 0 last
2055 foreach nn [lsort [array names profile *,host]] {
2056 if {[string length $profile($nn)]} {
2057 set ll [expr {[string length $nn] - 6}]
2058 set n [string range $nn 0 $ll]
2060 set nl $profile($n,windowNumber)
2061 if {[info exists profile($n,databases)]} {
2062 set ndb [llength $profile($n,databases)]
2067 .top.target.m.clist add cascade -label $n \
2068 -menu .top.target.m.clist.$nl
2069 irmenu .top.target.m.clist.$nl
2070 foreach b $profile($n,databases) {
2071 .top.target.m.clist.$nl add command -label $b \
2072 -command [list reopen-target $n $b]
2074 } elseif {$ndb == 1} {
2075 .top.target.m.clist add command -label $n -command \
2076 [list reopen-target $n [lindex $profile($n,databases) 0]]
2078 .top.target.m.clist add command -label $n -command \
2079 [list reopen-target $n {}]
2083 .top.target.m.slist delete 0 last
2084 foreach nn [lsort [array names profile *,host]] {
2085 set ll [expr {[string length $nn] - 6}]
2086 set n [string range $nn 0 $ll]
2087 .top.target.m.slist add command -label $n -command [list protocol-setup $n]
2091 # Procedure query-select {i}
2092 # i Query type number (integer)
2093 # This procedure is called when the user selects a Query type. The current
2094 # query type information given by the globals $queryButtonsFind and
2095 # $queryInfoFind are affected by this operation.
2096 proc query-select {i} {
2097 global queryButtonsFind queryInfoFind queryButtons queryInfo queryAuto queryAutoOld hostid currentDb profile
2099 if {$queryAutoOld == 1 && $queryAuto == 0} {
2100 set queryAutoOld $queryAuto
2103 if {$queryAutoOld == 0 && $queryAuto == 1 && [info exists profile($hostid,AttributeDetails,$currentDb,Bib1Use)] == 0} {
2104 set queryAutoOld $queryAuto
2107 set queryInfoFind [lindex $queryInfo $i]
2108 set queryButtonsFind [lindex $queryButtons $i]
2109 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2112 # Procedure query-new-action
2113 # Commits a new query type definition by extending the globals
2114 # $queryTypes, $queryButtons and $queryInfo.
2115 proc query-new-action {} {
2116 global queryTypes queryButtons queryInfo settingsChanged
2118 set settingsChanged 1
2119 lappend queryTypes [.query-new.top.index.entry get]
2120 lappend queryButtons {}
2121 lappend queryInfo {}
2127 # Procedure query-new
2128 # Makes a dialog in which the user is requested to enter the name of a
2134 set oldFocus [focus]
2138 pack $w.top.index -side top -anchor e -pady 2
2139 entry-fields $w.top index {{Query Name:}} \
2140 query-new-action {destroy .query-new}
2141 top-down-ok-cancel $w query-new-action 1
2145 # Procedure query-delete-action {queryNo}
2146 # queryNo query type number (integer)
2147 # Procedure that deletes the query type specified by $queryNo.
2148 proc query-delete-action {queryNo} {
2149 global queryTypes queryButtons queryInfo settingsChanged
2151 set settingsChanged 1
2153 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
2154 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
2155 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
2156 destroy .query-delete
2160 # Procedure query-delete {queryNo}
2161 # queryNo query type number (integer)
2162 # Asks if the user really want to delete a given query type; calls
2163 # query-delete-action if 'yes'.
2164 proc query-delete {queryNo} {
2172 set n [lindex $queryTypes $queryNo]
2174 label $w.top.warning -bitmap warning
2175 message $w.top.quest -text "Are you sure you want to delete the \
2176 query type $n ?" -aspect 300
2177 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
2178 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
2179 {Cancel} [list destroy $w]] 1
2182 # Procedure cascade-query-list
2183 # Updates the entries below Options|Query to list all query types.
2184 proc cascade-query-list {} {
2185 global queryTypes hostid queryAuto attributeTypes
2186 set w .top.options.m.query
2188 $w.clist delete 0 last
2189 foreach n $queryTypes {
2191 $w.clist add check -label $n -variable queryAuto -command [list query-select $i]
2193 $w.clist add command -label $n -command [list query-select $i]
2198 $w.slist delete 0 last
2199 foreach n $queryTypes {
2201 if {$hostid == "Default"} {
2202 $w.slist add command -label $n -state disabled -command [list query-setup $i]
2204 $w.slist add command -label $n -command [list query-setup $i]
2207 $w.slist add command -label $n -command [list query-setup $i]
2212 $w.tlist delete 0 last
2213 foreach n $attributeTypes {
2215 $w.tlist add check -label $n -variable attribute$n -command [list attribute-select $i]
2219 $w.dlist delete 0 last
2220 foreach n $queryTypes {
2221 $w.dlist add command -label $n -command [list query-delete $i]
2226 # Procedure save-geometry
2227 # This procedure saves the per-user related settings in ~/.clientrc.tcl.
2228 # The geometry information stored in the global array $windowGeometry is
2229 # saved. Also a few other user settings, such as current display format, are
2231 proc save-geometry {} {
2232 global windowGeometry hotTargets textWrap displayFormat popupMarcdf \
2233 recordSyntax elementSetNames hostid
2235 set windowGeometry(.) [wm geometry .]
2237 if {[catch {set f [open ~/.clientrc.tcl w]}]} {
2240 if {$hostid != "Default"} {
2241 puts $f "set hostid [list $hostid]"
2242 set b [z39 databaseNames]
2243 puts $f "set hostbase [list $b]"
2245 puts $f "set hotTargets [list $hotTargets]"
2246 puts $f "set textWrap $textWrap"
2247 puts $f "set displayFormat $displayFormat"
2248 puts $f "set popupMarcdf $popupMarcdf"
2249 puts $f "set recordSyntax $recordSyntax"
2250 puts $f "set elementSetNames $elementSetNames"
2251 foreach n [array names windowGeometry] {
2252 puts -nonewline $f "set [list windowGeometry($n)] "
2253 puts $f [list $windowGeometry($n)]
2258 # Procedure save-settings
2259 # This procedure saves the per-host related settings irtdb.tcl which
2260 # is normally kept in the directory /usr/local/lib/irtcl.
2261 # All query types and target defintion profiles are saved.
2262 proc save-settings {} {
2263 global profile libdir settingsChanged queryTypes queryButtons queryInfo queryAuto attributeTypes attributeTypeSelected
2265 if {[file writable [file join $libdir irtdb.tcl]]} {
2266 set f [open [file join $libdir irtdb.tcl] w]
2268 set f [open "irtdb.tcl" w]
2270 puts $f "# Setup file"
2271 foreach n [lsort [array names profile]] {
2272 puts $f "set [list profile($n)] [list $profile($n)]"
2274 puts $f "set attributeTypes [list $attributeTypes]"
2275 puts $f "set attributeTypeSelected [list $attributeTypeSelected]"
2276 puts $f "set queryTypes [list $queryTypes]"
2277 puts $f "set queryButtons [list $queryButtons]"
2278 puts $f "set queryInfo [list $queryInfo]"
2279 puts $f "set queryAuto [list $queryAuto]"
2281 set settingsChanged 0
2284 # Procedure alert {ask}
2286 # Makes a grabbed dialog in which the user is requested to answer
2287 # "Ok" or "Cancel". This procedure returns 1 if the user hits "Ok"; 0
2292 global alertAnswer font
2295 set oldFocus [focus]
2299 label $w.top.warning -bitmap warning
2300 message $w.top.message -text $ask -aspect 300 -font $font(b,normal)
2301 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
2304 top-down-ok-cancel $w {alert-action} 1
2309 # Procedure alert-action
2310 # Called when the user hits "Ok" in the .alert-window.
2311 proc alert-action {} {
2317 # Procedure exit-action
2318 # This procedure is called if the user exists the application
2319 proc exit-action {} {
2320 global settingsChanged
2322 if {$settingsChanged} {
2329 # Procedure listbuttonaction {w name h user i}
2330 # w menubutton widget
2331 # name name information
2332 # h handler to be invoked
2333 # user user information to be passed to handler $h
2334 # i index passed as second argument to handler $h
2335 # Utility function to emulate a listbutton. Called when the user
2336 # Modifies the listbutton. See procedure listbuttonx.
2337 proc listbuttonaction {w name h user i} {
2338 $w configure -text [lindex $name 0]
2339 $h [lindex $name 1] $user $i
2342 # Procedure listbuttonx {button no names handle user}
2343 # button menubutton widget
2344 # no initial value index (integer)
2345 # names list of name entries. The first entry in each name
2346 # entry is the actual name
2347 # handle user function to be called when the listbutton changes
2349 # user user argument to the $handle function
2350 # Makes an extended listbutton.
2351 proc listbuttonx {button no names handle user} {
2353 foreach name $names {
2354 set buttonName [lindex $name 0]
2355 if {[string length $buttonName] > $width} {
2356 set width [string length $buttonName]
2359 if {[winfo exists $button]} {
2360 $button configure -width $width -text [lindex [lindex $names $no] 0]
2361 ${button}.m delete 0 last
2363 menubutton $button -text [lindex [lindex $names $no] 0] \
2364 -width $width -menu ${button}.m -relief raised -border 1
2366 ${button}.m configure -tearoff off
2369 foreach name $names {
2370 ${button}.m add command -label [lindex $name 0] \
2371 -command [list listbuttonaction ${button} $name $handle $user $i]
2376 # Procedure listbutton {button no names}
2377 # button menubutton widget
2378 # no initial value index (integer)
2379 # names list of possible values.
2380 # Makes a listbutton. The functionality is emulated by the use menubutton-
2382 proc listbutton {button no names} {
2383 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
2384 -relief raised -border 1
2386 ${button}.m configure -tearoff off
2387 foreach name $names {
2388 ${button}.m add command -label $name \
2389 -command [list ${button} configure -text $name]
2393 # Procedure listbuttonv-action {button var names i}
2394 # button menubutton widget
2395 # var global variable to be affected
2396 # names list of possible names and values
2397 # This procedure is called when the user alters a menu created by the
2398 # listbuttonv procedure. The global variable $var is updated.
2399 proc listbuttonv-action {button var names i} {
2402 set $var [lindex $names [expr {$i+1}]]
2403 $button configure -text [lindex $names $i]
2406 # Procedure listbuttonv {button var names}
2407 # button menubutton widget
2408 # var global variable to be affected
2409 # names List of name/value pairs, i.e. {n1 v1 n2 v2 ...}.
2410 # This procedure emulates a listbutton by means of menu/menubutton widgets.
2411 # The global variable $var is automatically updated and set to one of the
2412 # values v1, v2, ...
2413 proc listbuttonv {button var names} {
2418 set l [llength $names]
2419 for {set i 1} {$i < $l} {incr i 2} {
2420 if {$val == [lindex $names $i]} {
2422 set n [lindex $names $i]
2426 if {[winfo exists $button]} {
2427 $button configure -text $n
2430 menubutton $button -text $n -menu ${button}.m -relief raised -border 1
2432 ${button}.m configure -tearoff off
2433 for {set i 0} {$i < $l} {incr i 2} {
2434 ${button}.m add command -label [lindex $names $i] \
2435 -command [list listbuttonv-action $button $var $names $i]
2439 # Procedure query-add-index-action {queryNo}
2440 # queryNo query type number (integer)
2441 # Handler that makes a new query index.
2442 proc query-add-index-action {queryNo} {
2445 global queryInfoTmp queryButtonsTmp
2447 set newI [.query-add-index.top.index.entry get]
2448 lappend queryInfoTmp [list $newI {}]
2449 $w.top.index.list insert end $newI
2450 destroy .query-add-index
2451 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2454 # Procedure query-add-line
2455 # queryNo query type number (integer)
2456 # Handler that adds new query line.
2457 proc query-add-line {queryNo} {
2460 global queryInfoTmp queryButtonsTmp
2462 lappend queryButtonsTmp {I 0}
2464 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2467 # Procedure query-del-line
2468 # queryNo query type number (integer)
2469 # Handler that removes query line.
2470 proc query-del-line {queryNo} {
2473 global queryInfoTmp queryButtonsTmp
2475 set l [llength $queryButtonsTmp]
2480 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
2481 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2484 # Procedure query-add-index
2485 # queryNo query type number (integer)
2486 # Handler that adds new query index.
2487 proc query-add-index {queryNo} {
2488 set w .query-add-index
2491 set oldFocus [focus]
2492 place-force $w .query-setup
2495 pack $w.top.index -side top -anchor e -pady 2
2496 entry-fields $w.top {index} {{Index Name:}} \
2497 [list query-add-index-action $queryNo] [list destroy $w]
2498 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
2502 # Procedure query-setup-action
2503 # queryNo query type number (integer)
2504 # Handler that updates the query information database stored in the
2505 # globals $queryInfo and $queryButtons. This procedure is executed when
2506 # the user commits the query setup changes by pressing button "Ok".
2507 proc query-setup-action {queryNo} {
2508 global queryButtons queryInfo queryButtonsTmp queryInfoTmp queryButtonsFind \
2509 queryInfoFind settingsChanged hostid currentDb profile
2510 set settingsChanged 1
2511 set queryInfo [lreplace $queryInfo $queryNo $queryNo $queryInfoTmp]
2512 set queryButtons [lreplace $queryButtons $queryNo $queryNo $queryButtonsTmp]
2513 if {[info exists profile($hostid,AttributeDetails,$currentDb,Bib1Use)]} {
2514 set profile($hostid,queryButtons,$currentDb) $queryButtonsTmp
2516 set queryInfoFind $queryInfoTmp
2517 set queryButtonsFind $queryButtonsTmp
2518 destroy .query-setup
2519 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2522 #This procedure handles selection of what attribute set the user wants to use for searching.
2523 #queryNo index in the attributeTypes list (also the menu item number in Query|Type).
2524 proc attribute-select {queryNo} {
2525 global attributeTypes attributeTypeSelected
2526 set attributeTypeSelected [lindex $attributeTypes $queryNo]
2527 foreach type $attributeTypes {
2528 global attribute[set type]
2529 set attribute$type 0
2531 set attribute[lindex $attributeTypes $queryNo] 1
2534 #proc changeQueryButtons {target base}
2537 #Substitutes the third element (the Auto element) in queryButtons with
2538 #profile(target,queryButtons,base). The third element in queryInfo is also substituted with
2539 #profile(target,AttributeDetails,base,Bib1Use)
2540 proc changeQueryButtons {target base} {
2542 global profile queryButtons queryInfo
2543 if {[info exists profile($target,queryButtons,$base)]} {
2544 set queryButtons [lreplace $queryButtons 2 2 $profile($target,queryButtons,$base)]
2545 foreach tag $profile($target,AttributeDetails,$base,Bib1Use) {
2547 lappend tempList [list $bib1($tag) 1=$tag]
2550 set queryInfo [lreplace $queryInfo 2 2 $tempList]
2554 # Procedure activate-e-index {value no i}
2556 # no query index number
2557 # i menu index (integer)
2558 # Procedure called when listbutton is activated in the query type edit
2559 # window. The global $queryButtonsTmp is updated in this operation.
2560 proc activate-e-index {value no i} {
2561 global queryButtonsTmp queryIndexTmp
2562 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
2563 dputs $queryButtonsTmp
2564 set queryIndexTmp $i
2567 # Procedure activate-index {value no i}
2569 # no query index number
2570 # i menu index (integer)
2571 # Procedure called when listbutton is activated in the main query
2572 # window. The global $queryButtonsFind is updated in this operation.
2573 proc activate-index {value no i} {
2574 global queryButtonsFind
2576 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
2577 dputs "queryButtonsFind $queryButtonsFind"
2580 # Procedure update-attr
2581 # This procedure creates listbuttons for all bib-1 attributes except
2582 # the use-attribute in the .index-setup window.
2583 # The globals $relationTmpValue, $positionTmpValue, $structureTmpValue,
2584 # $truncationTmpValue and $completenessTmpValue are maintainted by the
2586 proc update-attr {} {
2588 listbuttonv $w.top.relation.b relationTmpValue\
2589 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
2590 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
2591 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
2592 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
2593 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
2594 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
2595 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
2596 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
2597 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
2598 {local-number} 107 {string} 108 {numeric string} 109}
2599 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2600 {Left} 2 {Left and right} 3 {No truncation} 100 \
2601 {Process #} 101 {Re-1} 102 {Re-2} 103}
2602 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2603 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2606 # Procedure use-attr {init}
2608 # This procedure creates a listbox with several Bib-1 use attributes.
2609 # If $init is 1 the listbox is created with the attributes. If $init
2610 # is 0 the current selection of the listbox is read and the global
2611 # $useTmpValue is set to the current use-value.
2612 proc use-attr {init} {
2626 {BNB card number} 10
2627 {BGF(sic) number} 11
2629 {Dewey classification} 13
2630 {UDC classification} 14
2631 {Bliss classification} 15
2633 {NLM call number} 17
2634 {NAL call number} 18
2635 {MOS call number} 19
2636 {Local classification} 20
2637 {Subject heading} 21
2639 {BDI-index-subject} 23
2643 {LC-subject-heading} 27
2644 {RVM-subject-heading} 28
2645 {Local subject index} 29
2647 {Date of publication} 31
2648 {Date of acquisition} 32
2650 {Title-collective} 34
2653 {Title-added-title-page} 37
2657 {Title-other-variant} 41
2659 {Title-abbreviated} 43
2663 {Subject-subdivision} 47
2664 {Number-natl-bibliography} 48
2665 {Number-legal-deposit} 49
2666 {Number-govt-publication} 50
2667 {Number-publisher-for-music} 51
2669 {Number-local-call} 53
2671 {Code-geographic-area} 55
2672 {Code-institution} 56
2674 {Name-geographic} 58
2675 {Place-publication} 59
2677 {Microform-generation} 61
2684 {Author-name-personal} 1004
2685 {Author-name-corporate} 1005
2686 {Author-name-conference} 1006
2687 {Identifier-standard} 1007
2688 {Subject-LC-children's} 1008
2689 {Subject-name-personal} 1009
2691 {Date/time added to database} 1011
2692 {Date/time last modified} 1012
2693 {Authority/format identifier} 1013
2695 {Concept-reference} 1015
2697 {Server choice} 1017
2699 {Record source} 1019
2702 {Geographic class} 1022
2706 {Related periodical} 1026
2707 {Report number} 1027
2709 {Thematic number} 1030
2710 {Material type} 1031
2721 for {set i 0} {$i < 1037} {incr i} {
2722 $w.top.use.list insert end $bib1($i)
2724 if {$useTmpValue == $bib1($i)} {
2732 $w.top.use.list selection clear 0 end
2733 $w.top.use.list selection set $s $s
2738 $w.top.use.list yview $s
2740 set lno [lindex [$w.top.use.list curselection] 0]
2741 set i [expr {$lno+$lno+1}]
2742 set useTmpValue $bib1($i)
2743 dputs "useTmpValue=$useTmpValue"
2747 # Procedure index-setup-action {oldAttr queryNo indexNo}
2748 # oldAttr original attributes (?)
2749 # queryNo query number
2750 # indexNo index number
2751 # Commits setup of a query index. The mapping from the index to
2752 # the Bib-1 attributes are handled by this function.
2753 proc index-setup-action {oldAttr queryNo indexNo} {
2754 set attr [lindex $oldAttr 0]
2756 global useTmpValue relationTmpValue structureTmpValue truncationTmpValue \
2757 completenessTmpValue positionTmpValue queryInfoTmp
2761 dputs "index-setup-action"
2762 dputs "queryNo $queryNo"
2763 dputs "indexNo $indexNo"
2764 if {$useTmpValue > 0} {
2765 lappend attr "1=$useTmpValue"
2767 if {$relationTmpValue > 0} {
2768 lappend attr "2=$relationTmpValue"
2770 if {$positionTmpValue > 0} {
2771 lappend attr "3=$positionTmpValue"
2773 if {$structureTmpValue > 0} {
2774 lappend attr "4=$structureTmpValue"
2776 if {$truncationTmpValue > 0} {
2777 lappend attr "5=$truncationTmpValue"
2779 if {$completenessTmpValue > 0} {
2780 lappend attr "6=$completenessTmpValue"
2782 dputs "new attr $attr"
2783 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2784 destroy .index-setup
2787 # Procedure index-setup {attr queryNo indexNo}
2788 # attr original attributes
2789 # queryNo query number
2790 # indexNo index number
2791 # Makes a window with settings of a given query index which the user
2792 # may inspect/modify.
2793 proc index-setup {attr queryNo indexNo} {
2796 global relationTmpValue structureTmpValue truncationTmpValue \
2797 completenessTmpValue positionTmpValue useTmpValue
2798 set relationTmpValue 0
2799 set truncationTmpValue 0
2800 set structureTmpValue 0
2801 set positionTmpValue 0
2802 set completenessTmpValue 0
2808 set n [lindex $attr 0]
2809 wm title $w "Index setup $n"
2813 set len [llength $attr]
2814 for {set i 1} {$i < $len} {incr i} {
2815 set q [lindex $attr $i]
2816 set l [string first = $q]
2818 set t [string range $q 0 [expr {$l - 1}]]
2819 set v [string range $q [expr {$l + 1}] end]
2822 { set useTmpValue $v }
2824 { set relationTmpValue $v }
2826 { set positionTmpValue $v }
2828 { set structureTmpValue $v }
2830 { set truncationTmpValue $v }
2832 { set completenessTmpValue $v }
2837 frame $w.top.use -relief ridge -border 2
2838 frame $w.top.relation -relief ridge -border 2
2839 frame $w.top.position -relief ridge -border 2
2840 frame $w.top.structure -relief ridge -border 2
2841 frame $w.top.truncation -relief ridge -border 2
2842 frame $w.top.completeness -relief ridge -border 2
2848 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2850 label $w.top.use.label -text "Use"
2851 listbox $w.top.use.list -width 26 -yscrollcommand "$w.top.use.scroll set"
2852 scrollbar $w.top.use.scroll -orient vertical -border 1
2853 pack $w.top.use.label -side top -fill x -padx 2 -pady 2
2854 pack $w.top.use.list -side left -fill both -expand yes -padx 2 -pady 2
2855 pack $w.top.use.scroll -side right -fill y -padx 2 -pady 2
2856 $w.top.use.scroll config -command "$w.top.use.list yview"
2860 # Relation Attributes
2862 pack $w.top.relation -pady 6 -padx 6 -side top
2863 label $w.top.relation.label -text "Relation" -width 18
2865 pack $w.top.relation.label $w.top.relation.b -fill x
2867 # Position Attributes
2869 pack $w.top.position -pady 6 -padx 6 -side top
2870 label $w.top.position.label -text "Position" -width 18
2872 pack $w.top.position.label $w.top.position.b -fill x
2874 # Structure Attributes
2876 pack $w.top.structure -pady 6 -padx 6 -side top
2877 label $w.top.structure.label -text "Structure" -width 18
2879 pack $w.top.structure.label $w.top.structure.b -fill x
2881 # Truncation Attributes
2883 pack $w.top.truncation -pady 6 -padx 6 -side top
2884 label $w.top.truncation.label -text "Truncation" -width 18
2886 pack $w.top.truncation.label $w.top.truncation.b -fill x
2888 # Completeness Attributes
2890 pack $w.top.completeness -pady 6 -padx 6 -side top
2891 label $w.top.completeness.label -text "Completeness" -width 18
2893 pack $w.top.completeness.label $w.top.completeness.b -fill x
2896 bottom-buttons $w [list \
2897 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2898 {Cancel} [list destroy $w]] 0
2902 # Procedure query-edit-index {queryNo}
2903 # queryNo query number
2904 # Determines if a selection of an index is active. If one is selected
2905 # the index-setup dialog is started.
2906 proc query-edit-index {queryNo} {
2910 set i [lindex [$w.top.index.list curselection] 0]
2911 if {![string length $i]} {
2914 set attr [lindex $queryInfoTmp $i]
2915 dputs "Editing no $i $attr"
2916 index-setup $attr $queryNo $i
2919 # Procedure query-delete-index {queryNo}
2920 # queryNo query number
2921 # Determines if a selection of an index is active. If one is selected
2922 # the index is deleted.
2923 proc query-delete-index {queryNo} {
2924 global queryInfoTmp queryButtonsTmp
2927 set i [lindex [$w.top.index.list curselection] 0]
2928 if {![string length $i]} {
2931 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2932 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2933 $w.top.index.list delete $i
2936 # Procedure query-setup {queryNo}
2937 # queryNo query number
2938 # Makes a dialog in which a query type an be customized.
2939 proc query-setup {queryNo} {
2942 global queryTypes queryButtons queryInfo queryButtonsTmp queryInfoTmp queryIndexTmp
2945 set queryName [lindex $queryTypes $queryNo]
2946 set queryInfoTmp [lindex $queryInfo $queryNo]
2947 set queryButtonsTmp [lindex $queryButtons $queryNo]
2952 wm title $w "Query setup $queryName"
2956 frame $w.top.lines -relief ridge -border 2
2957 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2961 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2963 button $w.top.lines.add -text "Add" -command [list query-add-line $queryNo]
2964 button $w.top.lines.del -text "Remove" -command [list query-del-line $queryNo]
2965 pack $w.top.lines.del -fill x -side bottom
2966 pack $w.top.lines.add -fill x -pady 10 -side bottom
2970 frame $w.top.index -relief ridge -border 2
2971 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2973 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2974 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2975 -command [list $w.top.index.list yview]
2976 bind $w.top.index.list <Double-1> [list query-edit-index $queryNo]
2978 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2979 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2981 $w.top.index.list selection clear 0 end
2982 $w.top.index.list selection set 0 0
2983 foreach x $queryInfoTmp {
2984 $w.top.index.list insert end [lindex $x 0]
2988 bottom-buttons $w [list \
2989 Ok [list query-setup-action $queryNo] \
2990 Add [list query-add-index $queryNo] \
2991 Edit [list query-edit-index $queryNo] \
2992 Delete [list query-delete-index $queryNo] \
2993 Cancel [list destroy $w]] 0
2996 # Procedure index-clear
2997 # Handler that clears the search entry fields.
2998 proc index-clear {} {
2999 global queryButtonsFind
3002 foreach b $queryButtonsFind {
3003 .lines.$i.e delete 0 end
3008 # Procedure index-query
3009 # The purpose of this function is to read the user's query and convert
3010 # it to the prefix query that IrTcl/YAZ uses to represent an RPN query.
3011 # Each entry in a search fields takes the form
3013 # Here, relOp is an optional relational operator and one of:
3015 # which sets the Bib-1 relation to greater-than, less-than, etc.
3016 # The ? (question-mark) is also optional. A (?) on left-side indicates
3017 # left truncation; (?) on right-side indicates right-truncation; (?)
3018 # on both sides indicates both-left-and-right truncation.
3019 proc index-query {} {
3020 global queryButtonsFind queryInfoFind attributeTypeSelected
3025 foreach b $queryButtonsFind {
3026 set term [string trim [.lines.$i.e get]]
3028 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
3031 set len [string length $term]
3035 if {[string index $term 0] == ">"} {
3036 if {[string index $term 1] == "=" } {
3037 set term [string trim [string range $term 2 $len]]
3040 set term [string trim [string range $term 1 $len]]
3043 } elseif {[string index $term 0] == "<"} {
3044 if {[string index $term 1] == "=" } {
3045 set term [string trim [string range $term 2 $len]]
3047 } elseif {[string index $term 1] == ">"} {
3048 set term [string trim [string range $term 2 $len]]
3051 set term [string trim [string range $term 1 $len]]
3056 set len [string length $term]
3060 if {[string index $term $len] == "?"} {
3062 set term [string range $term 0 [expr {$len - 1}]]
3064 if {[string index $term 0] == "?"} {
3066 set term [string range $term 1 end]
3068 set term "\{${term}\}"
3069 if {$right && $left} {
3070 set term "@attrset $attributeTypeSelected @attr 5=3 ${term}"
3072 set term "@attrset $attributeTypeSelected @attr 5=1 ${term}"
3074 set term "@attrset $attributeTypeSelected @attr 5=2 ${term}"
3076 if {$relation != ""} {
3077 set term "@attrset $attributeTypeSelected @attr 2=${relation} ${term}"
3080 set term "@attrset $attributeTypeSelected @attr $a ${term}"
3083 set qs "@and ${qs} ${term}"
3094 # Procedure index-focus-in {w i}
3097 # This procedure handles <FocusIn> events. A red border is drawed
3098 # around the active search entry field.
3099 proc index-focus-in {w i} {
3100 global curIndexEntry
3101 $w.$i configure -background red
3102 set curIndexEntry $i
3105 # Procedure index-lines {w readOp buttonInfo queryInfo handle}
3106 # w search fields entry frame
3107 # realOp if true, search-request bindings are bound to the entries.
3108 # buttonInfo query type button information
3109 # queryInfo query type field information
3110 # handle handler called a when a 'listbutton' changes its value
3111 # Makes one or more search areas - with listbuttons on the left
3112 # and entries on the right.
3113 proc index-lines {w realOp buttonInfo queryInfo handle} {
3115 foreach b $buttonInfo {
3116 if {! [winfo exists $w.$i]} {
3117 frame $w.$i -border 0
3119 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
3122 if {! [winfo exists $w.$i.e]} {
3123 entry $w.$i.e -width 32 -relief sunken -border 1
3124 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
3125 bind $w.$i.e <FocusOut> [list $w.$i configure -background white]
3126 pack $w.$i.l -side left
3127 pack $w.$i.e -side left -fill x -expand yes
3128 pack $w.$i -side top -fill x -padx 2 -pady 2
3129 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
3130 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
3131 bind $w.$i.e <Return> {search-request 0}
3134 pack $w.$i.l -side left
3135 pack $w.$i -side top -fill x -padx 2 -pady 2
3140 while {[winfo exists $w.$j]} {
3150 set k [expr {$j + 1}]
3151 bind $w.$j.e <Tab> "focus $w.$k.e"
3155 bind $w.$i.e <Tab> "focus $w.0.e"
3160 #Procedure configureOptionsSyntax {target base}
3163 #Changes the Options|Syntax menu acording to the information obtained via explain.
3164 proc configureOptionsSyntax {target base} {
3165 global profile syntaxList recordSyntax
3168 set w .top.options.m.syntax
3169 if {[info exists profile($target,RecordSyntaxes,$base)]} {
3170 foreach syntax $syntaxList {
3172 if {$syntax == "sep"} {continue}
3173 if {[lsearch $profile($target,RecordSyntaxes,$base) $syntax] != -1} {
3174 configure-enable-e $w $i
3175 if {$activate == 0} {
3177 set recordSyntax $syntax
3181 configure-disable-e $w $i
3185 foreach syntax $syntaxList {
3187 if {$syntax == "sep"} {continue}
3188 configure-enable-e $w $i
3194 # Init: The geometry information for the main window is set - either
3195 # to a default value or to the value in windowGeometry(.)
3196 if {[catch {set g $windowGeometry(.)}]} {
3197 wm geometry . 420x340
3202 # Init: Presentation formats are read.
3205 # Init: The main window is defined.
3206 frame .top -border 1 -relief raised
3207 frame .lines -border 1 -relief raised
3208 frame .mid -border 1 -relief raised
3209 frame .data -border 1 -relief raised
3210 frame .bot -border 1 -relief raised
3211 pack .top .lines .mid -side top -fill x
3212 pack .data -side top -fill both -expand yes
3215 # Init: Definition of File menu.
3216 menubutton .top.file -text File -menu .top.file.m
3218 .top.file.m add command -label {Save settings} -command {save-settings}
3219 .top.file.m add separator
3220 .top.file.m add command -label Exit -command {exit-action}
3222 # Init: Definition of Target menu.
3223 menubutton .top.target -text Target -menu .top.target.m
3224 irmenu .top.target.m
3225 .top.target.m add cascade -label Connect -menu .top.target.m.clist
3226 .top.target.m add command -label Disconnect -command {close-target}
3227 .top.target.m add command -label About -command {about-target}
3228 .top.target.m add cascade -label Setup -menu .top.target.m.slist
3229 .top.target.m add command -label {Setup new} -command {define-target-dialog}
3230 .top.target.m add separator
3231 set-target-hotlist 0
3233 configure-disable-e .top.target.m 1
3234 configure-disable-e .top.target.m 2
3236 irmenu .top.target.m.clist
3237 irmenu .top.target.m.slist
3240 # Init: Definition of Service menu.
3241 menubutton .top.service -text Service -menu .top.service.m
3242 irmenu .top.service.m
3243 .top.service.m add cascade -label Database -menu .top.service.m.dblist
3244 .top.service.m add cascade -label Present -menu .top.service.m.present
3245 irmenu .top.service.m.present
3246 .top.service.m.present add command -label {10 More} -command [list present-more 10]
3247 .top.service.m.present add command -label All -command [list present-more {}]
3248 .top.service.m add command -label Search -command {search-request 0}
3249 .top.service.m add command -label Scan -command {scan-request}
3250 .top.service.m add command -label Explain -command \
3251 {explain-refresh $hostid {ready-response {}} }
3253 .top.service configure -state disabled
3255 irmenu .top.service.m.dblist
3257 # Init: Definition of Set menu.
3258 menubutton .top.rset -text Set -menu .top.rset.m
3260 .top.rset.m add command -label Load -command {load-set}
3261 .top.rset.m add separator
3263 # Init: Definition of the Options menu.
3264 menubutton .top.options -text Options -menu .top.options.m
3265 irmenu .top.options.m
3266 .top.options.m add cascade -label Query -menu .top.options.m.query
3267 .top.options.m add cascade -label Format -menu .top.options.m.formats
3268 .top.options.m add cascade -label Wrap -menu .top.options.m.wrap
3269 .top.options.m add cascade -label Syntax -menu .top.options.m.syntax
3270 .top.options.m add cascade -label Elements -menu .top.options.m.elements
3271 .top.options.m add radiobutton -label Debug -variable debugMode -value 1
3273 # Init: Definition of the Options|Query menu.
3274 irmenu .top.options.m.query
3275 .top.options.m.query add cascade -label Select -menu .top.options.m.query.clist
3276 .top.options.m.query add cascade -label Type -menu .top.options.m.query.tlist
3277 .top.options.m.query add cascade -label Edit -menu .top.options.m.query.slist
3278 .top.options.m.query add command -label New -command {query-new}
3279 .top.options.m.query add cascade -label Delete -menu .top.options.m.query.dlist
3281 irmenu .top.options.m.query.slist
3282 irmenu .top.options.m.query.tlist
3283 irmenu .top.options.m.query.clist
3284 irmenu .top.options.m.query.dlist
3287 # Init: Definition of the Options|Formats menu.
3288 irmenu .top.options.m.formats
3290 foreach f $displayFormats {
3291 .top.options.m.formats add radiobutton -label $f -value $i \
3292 -command [list set-display-format $i] -variable displayFormat
3296 # Init: Definition of the Options|Wrap menu.
3297 irmenu .top.options.m.wrap
3298 .top.options.m.wrap add radiobutton -label Character \
3299 -value char -variable textWrap -command {set-wrap char}
3300 .top.options.m.wrap add radiobutton -label Word \
3301 -value word -variable textWrap -command {set-wrap word}
3302 .top.options.m.wrap add radiobutton -label None \
3303 -value none -variable textWrap -command {set-wrap none}
3305 # Init: Definition of the Options|Syntax menu.
3306 proc initOptionsSyntax {} {
3307 global syntaxList recordSyntax
3308 set w .top.options.m.syntax
3310 foreach syntax $syntaxList {
3311 if {$syntax == "sep"} {
3314 $w add radiobutton -label $syntax -value $syntax -variable recordSyntax
3320 # Init: Definition of the Options|Elements menu.
3321 irmenu .top.options.m.elements
3322 .top.options.m.elements add radiobutton -label Unspecified \
3323 -value None -variable elementSetNames
3324 .top.options.m.elements add radiobutton -label Full -value F -variable elementSetNames
3325 .top.options.m.elements add radiobutton -label Brief -value B -variable elementSetNames
3327 # Init: Definition of Help menu.
3328 menubutton .top.help -text "Help" -menu .top.help.m
3331 #.top.help.m add command -label "Help on help" -command {tkerror "Help on help not available. Sorry"}
3332 .top.help.m add command -label "Help on help" -command {bgerror "Help on help not available. Sorry"}
3333 .top.help.m add command -label "About" -command {about-origin}
3335 # Init: Pack menu bar items.
3336 pack .top.file .top.target .top.service .top.rset .top.options -side left
3337 pack .top.help -side right
3339 # Init: Define query area.
3340 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
3341 image create photo scan -file [file join $libdir bitmaps a-z.gif]
3342 image create photo clear -file [file join $libdir bitmaps trash.gif]
3343 image create photo present -file [file join $libdir bitmaps page.gif]
3344 image create photo search -file [file join $libdir bitmaps search.gif]
3345 button .mid.search -image search -command {search-request 0} -state disabled -relief flat
3346 button .mid.scan -image scan -command scan-request -state disabled -relief flat
3347 button .mid.present -image present -command [list present-more 10] -state disabled -relief flat
3348 button .mid.clear -image clear -command index-clear -relief flat
3349 pack .mid.search .mid.scan .mid.present .mid.clear -side left -fill y -pady 1
3351 # Init: Define record area in main window.
3352 text .data.record -font fixed -height 2 -width 20 -wrap none -borderwidth 0 \
3353 -relief flat -yscrollcommand [list .data.scroll set] -wrap $textWrap
3354 scrollbar .data.scroll -command [list .data.record yview]
3355 .data.record configure -takefocus 0
3356 .data.scroll configure -takefocus 0
3358 pack .data.scroll -side right -fill y
3359 pack .data.record -expand yes -fill both
3362 # Init: Define standards tags. These are used in the display
3363 # format procedures.
3365 .data.record tag configure marc-tag -foreground blue
3366 .data.record tag configure marc-id -foreground red
3367 .data.record tag configure marc-data -foreground black
3368 .data.record tag configure marc-head -font $font(n,normal) \
3369 -foreground brown -relief raised -borderwidth 1
3370 .data.record tag configure marc-small-head -foreground brown
3371 .data.record tag configure marc-pref -font $font(n,normal) -foreground blue
3372 .data.record tag configure marc-text -font $font(n,normal) -foreground black
3373 .data.record tag configure marc-it -font $font(n,normal) -foreground black
3375 # Init: Define logo.
3376 button .bot.logo -bitmap @[file join $libdir bitmaps book1] -command cancel-operation
3377 .bot.logo configure -takefocus 0
3379 # Init: Define status information fields at the bottom.
3381 pack .bot.a -side left -fill x
3382 pack .bot.logo -side right -padx 2 -pady 2 -ipadx 1
3384 message .bot.a.target -text {} -aspect 2000 -border 1
3386 label .bot.a.status -text "Not connected" -width 15 -relief sunken -anchor w -border 1
3387 label .bot.a.set -text "" -width 5 -relief sunken -anchor w -border 1
3388 label .bot.a.message -text "" -width 15 -relief sunken -anchor w -border 1
3390 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
3391 pack .bot.a.status .bot.a.set .bot.a.message -side left -padx 2 -pady 2 -ipadx 1 -ipady 1
3393 # Init: Determine if the IrTcl extension is already there. If
3394 # not, then dynamically load the IrTcl extension.
3395 if {[catch {ir z39}]} {
3396 set e [info sharedlibextension]
3397 puts -nonewline "Loading irtcl$e ..."
3398 load [file join $libdir irtcl$e] irtcl
3403 if {[file exists [file join $libdir explain.tcl]]} {
3404 source [file join $libdir explain.tcl]
3407 #if {[file exists ${libdir}/setup.tcl]}
3408 source [file join $libdir setup.tcl]
3411 # Init: Uncomment this line if you wan't to enable logging.
3412 ir-log-init all irtcl irtcl.log
3414 # Init: If hostid is a valid target, a new connection will be established
3416 if {[string compare $hostid Default]} {
3417 catch {open-target $hostid $hostbase}
3420 # Init: Enable the logo.