1 # IR toolkit for tcl/tk
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
7 # Revision 1.81 1995-10-19 10:34:43 adam
8 # More configurable client.
10 # Revision 1.80 1995/10/18 17:20:32 adam
11 # Work on target setup in client.tcl.
13 # Revision 1.79 1995/10/18 16:42:37 adam
14 # New settings: smallSetElementSetNames and mediumSetElementSetNames.
16 # Revision 1.78 1995/10/18 15:45:36 quinn
17 # *** empty log message ***
19 # Revision 1.77 1995/10/18 15:37:46 adam
22 # Revision 1.76 1995/10/18 15:15:20 adam
25 # Revision 1.75 1995/10/17 14:18:05 adam
26 # Minor changes in presentation formats.
28 # Revision 1.74 1995/10/17 12:18:57 adam
29 # Bug fix: when target connection closed, the connection was not
30 # properly reestablished.
32 # Revision 1.73 1995/10/17 10:58:06 adam
33 # More work on presentation formats.
35 # Revision 1.72 1995/10/16 17:00:52 adam
36 # New setting: elementSetNames.
37 # Various client improvements. Medium presentation format looks better.
39 # Revision 1.71 1995/10/13 15:35:27 adam
40 # Relational operators may be used in search entries - changes
41 # in proc index-query.
43 # Revision 1.70 1995/10/12 14:46:52 adam
44 # Better record popup windows. Next/prev buttons in popup record windows.
45 # The record position in the raw format is much more visible.
47 # Revision 1.69 1995/09/21 13:42:54 adam
50 # Revision 1.68 1995/09/21 13:11:49 adam
51 # Support of dynamic loading.
52 # Test script uses load command if necessary.
54 # Revision 1.67 1995/09/20 14:35:19 adam
57 # Revision 1.66 1995/08/29 15:30:13 adam
58 # Work on GRS records.
60 # Revision 1.65 1995/08/24 15:39:09 adam
63 # Revision 1.64 1995/08/24 15:33:02 adam
66 # Revision 1.63 1995/08/04 13:20:48 adam
67 # Buttons at the bottom are slightly smaller.
69 # Revision 1.62 1995/08/04 11:32:37 adam
70 # More work on output queue. Memory related routines moved
73 # Revision 1.61 1995/07/20 08:09:39 adam
74 # client.tcl: Targets removed from hotTargets list when targets
75 # are removed/modified.
76 # ir-tcl.c: More work on triggerResourceControl.
78 # Revision 1.60 1995/06/30 16:30:19 adam
81 # Revision 1.59 1995/06/29 14:06:25 adam
82 # Another bug in install fixed. Configure searches for more versions of yaz.
84 # Revision 1.58 1995/06/29 12:34:06 adam
85 # IrTcl now works with both tk4.0b4/tcl7.4b4 and tk3.6/tcl7.3
87 # Revision 1.57 1995/06/29 09:20:30 adam
88 # Target entries in cascade menus are sorted.
90 # Revision 1.56 1995/06/27 19:03:48 adam
91 # Bug fix in do_present in ir-tcl.c: p->set_child member weren't set.
92 # nextResultSetPosition used instead of setOffset.
94 # Revision 1.55 1995/06/27 17:10:37 adam
95 # Bug fix: install procedure didn't work on some systems.
96 # Error turned up when clientrc.tcl was't present.
98 # Revision 1.54 1995/06/27 14:41:03 adam
99 # Bug fix in search-response. Didn't always observe non-surrogate diagnostics.
101 # Revision 1.53 1995/06/26 12:40:09 adam
102 # Client defines its own tkerror.
103 # User may specify 'no preferredRecordSyntax'.
105 # Revision 1.52 1995/06/22 13:14:59 adam
106 # Feature: SUTRS. Setting getSutrs implemented.
107 # Work on display formats.
108 # Preferred record syntax can be set by the user.
110 # Revision 1.51 1995/06/21 11:11:00 adam
111 # Bug fix: libdir undefined in about-origin.
113 # Revision 1.50 1995/06/21 11:04:48 adam
114 # Uses GNU autoconf 2.3.
115 # Install procedure implemented.
116 # boook bitmaps moved to sub directory bitmaps.
118 # Revision 1.49 1995/06/20 14:16:42 adam
119 # More work on cancel mechanism.
121 # Revision 1.48 1995/06/20 08:07:23 adam
122 # New setting: failInfo.
123 # Working on better cancel mechanism.
125 # Revision 1.47 1995/06/19 14:05:29 adam
126 # Bug fix: asked for SUTRS.
128 # Revision 1.46 1995/06/19 13:06:06 adam
129 # New define: IR_TCL_VERSION.
131 # Revision 1.45 1995/06/19 08:08:44 adam
132 # client.tcl: hotTargets now contain both database and target name.
133 # ir-tcl.c: setting protocol edited. Errors in callbacks are logged
134 # by logf(LOG_WARN, ...) calls.
136 # Revision 1.44 1995/06/16 14:55:18 adam
137 # Book logo mirrored.
139 # Revision 1.43 1995/06/16 14:41:05 adam
140 # Scan line entries can be copied to a search entry.
142 # Revision 1.42 1995/06/16 12:28:13 adam
143 # Implemented preferredRecordSyntax.
144 # Minor changes in diagnostic handling.
145 # Record list deleted when connection closes.
147 # Revision 1.41 1995/06/14 15:07:59 adam
148 # Bug fix in cascade-target-list. Uses yaz-version.h.
150 # Revision 1.40 1995/06/14 13:37:17 adam
151 # Setting recordType implemented.
152 # Setting implementationVersion implemented.
153 # Settings implementationId / implementationName edited.
155 # Revision 1.39 1995/06/14 12:16:22 adam
156 # hotTargets, textWrap and displayFormat saved in clientg.tcl.
158 # Revision 1.38 1995/06/14 07:22:45 adam
159 # Target definitions can be deleted.
160 # Listbox used in the query definition dialog.
162 # Revision 1.37 1995/06/13 14:37:59 adam
163 # Work on query setup.
164 # Better about origin/target.
165 # Better presentation formats.
167 # Revision 1.36 1995/06/13 07:42:14 adam
168 # Bindings removed from text widgets.
170 # Revision 1.35 1995/06/12 15:17:31 adam
171 # Text widget used in main window (instead of listbox) to support
172 # better presentation formats.
174 # Revision 1.34 1995/06/12 07:59:07 adam
175 # More work on geometry handling.
177 # Revision 1.33 1995/06/09 11:17:35 adam
178 # Start work on geometry management.
180 # Revision 1.32 1995/06/07 09:16:37 adam
181 # New presentation format.
183 # Revision 1.31 1995/06/06 16:31:09 adam
184 # Bug fix: target names couldn't contain blanks.
187 # Revision 1.30 1995/06/06 11:35:41 adam
188 # Work on scan. Display of old sets.
190 # Revision 1.29 1995/06/05 14:11:18 adam
191 # Bug fix in present-more.
193 # Revision 1.28 1995/06/02 14:52:13 adam
194 # Minor changes really.
196 # Revision 1.27 1995/06/02 14:29:42 adam
197 # Work on scan interface - up/down buttons.
199 # Revision 1.26 1995/06/01 16:36:46 adam
200 # About buttons. Minor bug fixes.
202 # Revision 1.25 1995/05/31 13:09:57 adam
203 # Client searches/presents may be interrupted.
204 # New moving book-logo.
206 # Revision 1.24 1995/05/31 08:36:24 adam
207 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
208 # New method: referenceId. More work on scan.
210 # Revision 1.23 1995/05/29 10:33:41 adam
211 # README and rename of startup script.
213 # Revision 1.22 1995/05/26 11:44:09 adam
214 # Bugs fixed. More work on MARC utilities and queries. Test
215 # client is up-to-date again.
217 # Revision 1.21 1995/05/11 15:34:46 adam
218 # Scan request changed a bit. This version works with RLG.
220 # Revision 1.20 1995/04/21 16:31:57 adam
221 # New radiobutton: protocol (z39v2/SR).
223 # Revision 1.19 1995/04/18 16:11:50 adam
224 # First version of graphical Scan. Some work on query-by-form.
226 # Revision 1.18 1995/04/10 10:50:22 adam
227 # Result-set name defaults to suffix of ir-set name.
228 # Started working on scan. Not finished at this point.
230 # Revision 1.17 1995/03/31 09:34:57 adam
231 # Search-button disabled when there is no connection.
233 # Revision 1.16 1995/03/31 08:56:36 adam
234 # New button "Search".
236 # Revision 1.15 1995/03/28 12:45:22 adam
237 # New ir method failback: called on disconnect/protocol error.
238 # New ir set/get method: protocol: SR / Z3950.
239 # Simple popup and disconnect when failback is invoked.
241 # Revision 1.14 1995/03/22 16:07:55 adam
244 # Revision 1.13 1995/03/21 17:27:26 adam
245 # Short-hand keys in setup.
247 # Revision 1.12 1995/03/21 13:41:03 adam
248 # Comstack cs_create not used too often. Non-blocking connect.
250 # Revision 1.11 1995/03/21 10:39:06 adam
251 # Diagnostic error message displayed with tkerror.
253 # Revision 1.10 1995/03/20 15:24:06 adam
254 # Diagnostic records saved on searchResponse.
256 # Revision 1.9 1995/03/17 18:26:16 adam
257 # Non-blocking i/o used now. Database names popup as cascade items.
259 # Revision 1.8 1995/03/17 15:45:00 adam
260 # Improved target/database setup.
262 # Revision 1.7 1995/03/16 17:54:03 adam
263 # Minor changes really.
265 # Revision 1.6 1995/03/15 19:10:20 adam
266 # Database setup in protocol-setup (rather target setup).
268 # Revision 1.5 1995/03/15 13:59:23 adam
271 # Revision 1.4 1995/03/14 17:32:29 adam
272 # Presentation of full Marc record in popup window.
274 # Revision 1.3 1995/03/12 19:31:52 adam
275 # Pattern matching implemented when retrieving MARC records. More
276 # diagnostic functions.
278 # Revision 1.2 1995/03/10 18:00:15 adam
279 # Actual presentation in line-by-line format. RPN query support.
281 # Revision 1.1 1995/03/09 16:15:07 adam
282 # First presentRequest attempts. Hot-target list.
286 if {$tk_version == "3.6"} {
297 proc configure-enable-e {w n} {
299 $w entryconfigure $n -state normal
301 proc configure-disable-e {w n} {
303 $w entryconfigure $n -state disabled
305 set noFocus [list -takefocus 0]
307 proc configure-enable-e {w n} {
310 proc configure-disable-e {w n} {
317 if {[tk colormodel .] == "color"} {
327 if {[file readable bitmaps/book2]} {
330 if {! [file readable ${libdir}/bitmaps/book2]} {
331 puts "Cannot locate system files in ${libdir}. You must either run this"
332 puts "program from the source directory root of ir-tcl or you must assure"
333 puts "that it is installed - normally in /usr/local/lib/irtcl"
341 set profile(Default) {{} {} {210} {} 50000 30000 tcpip {} 1 {} {} Z39 1 2 0 0 4}
343 set settingsChanged 0
351 set recordSyntax None
352 set elementSetNames None
355 set queryTypes {Simple}
356 set queryButtons { { {I 0} {I 1} {I 2} } }
357 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
358 {Subject {1=21}} {Any {1=1016}} } }
367 if {[winfo exists $w]} {
376 label $w.top.b -bitmap error
377 message $w.top.t -aspect 300 -text "Error: $err" \
378 -font -Adobe-Helvetica-Bold-R-Normal-*-180-*
379 pack $w.top.b $w.top.t -side left -padx 10 -pady 10
381 bottom-buttons $w [list {Close} [list destroy $w]] 1
384 if {[file readable "clientrc.tcl"]} {
385 source "clientrc.tcl"
387 if {[file readable "${libdir}/clientrc.tcl"]} {
388 source "${libdir}/clientrc.tcl"
392 if {[file readable "~/.clientrc.tcl"]} {
393 source "~/.clientrc.tcl"
396 set queryButtonsFind [lindex $queryButtons 0]
397 set queryInfoFind [lindex $queryInfo 0]
399 proc read-formats {} {
400 global displayFormats
402 if {[catch {set formats [glob -nocomplain ${libdir}/formats/*.tcl]}]} {
403 set formats ./formats/raw.tcl
406 if {[file readable $f]} {
408 set l [string length $f]
409 set f [string range $f [string length "${libdir}/formats/"] \
411 lappend displayFormats $f
420 .data.record configure -wrap $m
427 proc set-display-format {f} {
437 .bot.a.status configure -text "Reformatting"
440 add-title-lines -1 10000 1
443 proc initBindings {} {
446 bind $w <Double-1> {}
447 bind $w <Triple-1> {}
448 bind $w <B1-Motion> {}
450 bind $w <Shift-B1-Motion> {}
452 bind $w <B2-Motion> {}
453 bind $w <Any-KeyPress> {}
455 bind $w <BackSpace> {}
457 bind $w <Control-h> {}
458 bind $w <Control-d> {}
459 bind $w <Control-v> {}
462 bind $w <B1-Motion> {}
463 bind $w <Shift-B1-Motion> {}
468 proc post-menu {wbutton wmenu} {
471 $wmenu post [winfo rootx $wbutton] \
472 [expr [winfo rooty $wbutton]+[winfo height $wbutton]]
477 global windowGeometry
478 set windowGeometry($w) [wm geometry $w]
481 global windowGeometry
484 if {[info exists windowGeometry($w)]} {
485 set g $windowGeometry($w)
490 bind $w <Destroy> [list destroyGW $w]
494 proc top-down-window {w} {
495 frame $w.top -relief raised -border 1
496 frame $w.bot -relief raised -border 1
498 pack $w.top -side top -fill both -expand yes
499 pack $w.bot -fill both
502 proc top-down-ok-cancel {w ok-action g} {
503 frame $w.bot.left -relief sunken -border 1
504 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 1 -pady 1
505 button $w.bot.left.ok -width 4 -text {Ok} \
506 -command ${ok-action}
507 pack $w.bot.left.ok -expand yes -ipadx 1 -ipady 1 -padx 2 -pady 2
508 button $w.bot.cancel -width 5 -text {Cancel} \
509 -command [list destroy $w]
510 pack $w.bot.cancel -side left -expand yes
518 proc bottom-buttons {w buttonList g} {
520 set l [llength $buttonList]
522 frame $w.bot.$i -relief sunken -border 1
523 pack $w.bot.$i -side left -expand yes -padx 2 -pady 2
524 button $w.bot.$i.ok -text [lindex $buttonList $i] \
525 -command [lindex $buttonList [expr $i+1]]
526 pack $w.bot.$i.ok -expand yes -padx 2 -pady 2 -side left
530 button $w.bot.$i -text [lindex $buttonList $i] \
531 -command [lindex $buttonList [expr $i+1]]
532 pack $w.bot.$i -expand yes -padx 2 -pady 2 -side left
542 proc cancel-operation {} {
550 show-status Cancel 0 1
554 proc show-target {target base} {
558 .bot.a.target configure -text ""
562 .bot.a.target configure -text "$target"
564 .bot.a.target configure -text "$target - $base"
568 proc show-logo {v1} {
577 .bot.logo configure -bitmap @${libdir}/bitmaps/book${v1}
578 after 140 [list show-logo $v1]
582 .bot.logo configure -bitmap @${libdir}/bitmaps/book1
591 proc show-status {status b sb} {
598 .bot.a.status configure -text "$status"
600 if {$busy == 0} {set busy 1}
608 .top.service configure -state normal
609 .mid.search configure -state normal
611 .mid.scan configure -state normal
614 configure-disable-e .top.service.m 1
615 } elseif {[z39.$setNo nextResultSetPosition] > 0 &&
616 [z39.$setNo nextResultSetPosition] <= [z39.$setNo resultCount]} {
617 configure-enable-e .top.service.m 1
618 .mid.present configure -state normal
620 configure-disable-e .top.service.m 1
621 .mid.present configure -state disabled
623 if {[winfo exists .scan-window]} {
624 .scan-window.bot.2 configure -state normal
625 .scan-window.bot.4 configure -state normal
628 .top.service configure -state disabled
629 .mid.search configure -state disabled
630 .mid.scan configure -state disabled
631 .mid.present configure -state disabled
633 if {[winfo exists .scan-window]} {
634 .scan-window.bot.2 configure -state disabled
635 .scan-window.bot.4 configure -state disabled
640 proc show-message {msg} {
641 .bot.a.message configure -text "$msg"
644 proc insertWithTags {w text args} {
645 set start [$w index insert]
646 $w insert insert $text
647 foreach tag [$w tag names $start] {
648 $w tag remove $tag $start insert
651 $w tag add $i $start insert
655 proc popup-license {} {
660 wm title $w "License"
666 text $w.top.t -width 80 -height 10 -wrap word \
667 -yscrollcommand [list $w.top.s set]
668 scrollbar $w.top.s -command [list $w.top.t yview]
670 pack $w.top.s -side right -fill y
671 pack $w.top.t -expand yes -fill both
673 if {[file readable "${libdir}/LICENSE"]} {
674 set f [open "${libdir}/LICENSE" r]
675 while {[gets $f buf] != -1} {
676 $w.top.t insert end $buf
677 $w.top.t insert end "\n"
681 bottom-buttons $w [list {Close} [list destroy $w]] 1
684 proc about-target {} {
685 set w .about-target-w
690 wm title $w "About target"
694 frame $w.top.a -relief ridge -border 2
695 frame $w.top.p -relief ridge -border 2
697 pack $w.top.a $w.top.p -side top -fill x
699 label $w.top.a.about -text "About"
700 label $w.top.a.irtcl -text $hostid \
701 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
702 pack $w.top.a.about $w.top.a.irtcl -side top
704 set i [z39 targetImplementationName]
705 label $w.top.p.in -text "Implementation name: $i"
706 set i [z39 targetImplementationId]
707 label $w.top.p.ii -text "Implementation id: $i"
708 set i [z39 targetImplementationVersion]
709 label $w.top.p.iv -text "Implementation version: $i"
711 label $w.top.p.op -text "Protocol options: $i"
713 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
715 bottom-buttons $w [list {Close} [list destroy $w]] 1
718 proc about-origin-logo {n} {
720 set w .about-origin-w
721 if {![winfo exists $w]} {
728 $w.top.a.logo configure -bitmap @${libdir}/bitmaps/book$n
729 after 140 [list about-origin-logo $n]
732 proc about-origin {} {
733 set w .about-origin-w
737 if {[winfo exists $w]} {
742 wm title $w "About IrTcl"
746 frame $w.top.a -relief ridge -border 2
747 frame $w.top.p -relief ridge -border 2
749 pack $w.top.a $w.top.p -side top -fill x
751 label $w.top.a.irtcl -text "IrTcl" \
752 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
753 label $w.top.a.logo -bitmap @${libdir}/bitmaps/book1
754 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
757 catch {set i [z39 implementationName]}
758 label $w.top.p.in -text "Implementation name: $i"
759 catch {set i [z39 implementationId]}
760 label $w.top.p.ii -text "Implementation id: $i"
761 catch {set i [z39 implementationVersion]}
762 label $w.top.p.iv -text "Implementation version: $i"
764 label $w.top.p.tk -text "Tk version: $i"
766 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.tk -side top -anchor nw
769 bottom-buttons $w [list {Close} [list destroy $w] \
770 {License} [list popup-license]] 0
773 proc popup-marc {sno no b df} {
774 global displayFormats
777 if {[z39.$sno type $no] != "DB"} {
782 while {[winfo exists .full-marc$b]} {
788 if {![winfo exists $w]} {
793 frame $w.top -relief raised -border 1
794 frame $w.bot -relief raised -border 1
796 pack $w.top -side top -fill both -expand yes
797 pack $w.bot -fill both
799 text $w.top.record -width 60 -height 5 -wrap word \
800 -yscrollcommand [list $w.top.s set]
801 scrollbar $w.top.s -command [list $w.top.record yview]
805 $w.top.record tag configure marc-tag -foreground blue
806 $w.top.record tag configure marc-id -foreground red
808 $w.top.record tag configure marc-tag -foreground black
809 $w.top.record tag configure marc-id -foreground black
811 $w.top.record tag configure marc-data -foreground black
812 $w.top.record tag configure marc-head \
813 -font -Adobe-Times-Medium-R-Normal-*-180-* \
814 -background black -foreground white
816 $w.top.record tag configure marc-pref \
817 -font -Adobe-Times-Medium-R-Normal-*-180-* \
819 $w.top.record tag configure marc-text \
820 -font -Adobe-Times-Medium-R-Normal-*-180-* \
822 $w.top.record tag configure marc-it \
823 -font -Adobe-Times-Medium-I-Normal-*-180-* \
826 pack $w.top.s -side right -fill y
827 pack $w.top.record -expand yes -fill both
829 bottom-buttons $w [list \
830 {Close} [list destroy $w] \
834 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m \
836 menu $w.bot.formats.m
837 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 \
838 -padx 3 -pady 3 -side left
840 $w.bot.formats.m delete 0 last
843 foreach f $displayFormats {
844 $w.bot.formats.m add radiobutton -label $f \
845 -variable popupMarcdf -value $i \
846 -command [list popup-marc $sno $no $b 0]
849 $w.top.record delete 0.0 end
850 set recordType [z39.$sno recordType $no]
851 wm title $w "$recordType record #$no"
853 $w.bot.2 configure -command \
854 [list popup-marc $sno [expr $no-1] $b $df]
855 $w.bot.4 configure -command \
856 [list popup-marc $sno [expr $no+1] $b $df]
858 $w.bot.2 configure -state disabled
860 $w.bot.2 configure -state normal
862 if {[z39.$sno type [expr $no+1]] != "DB"} {
863 $w.bot.4 configure -state disabled
865 $w.bot.4 configure -state normal
867 $w.bot.6 configure -command [list popup-marc $sno $no -1 0]
868 set ffunc [lindex $displayFormats $df]
869 set ffunc "display-$ffunc"
871 $ffunc $sno $no $w.top.record 0
874 proc update-target-hotlist {target base} {
877 set olen [llength $hotTargets]
879 foreach e $hotTargets {
880 if {$target == [lindex $e 0] && $base == [lindex $e 1]} {
881 set hotTargets [lreplace $hotTargets $i $i]
886 set hotTargets [linsert $hotTargets 0 [list $target $base]]
887 set-target-hotlist $olen
890 proc delete-target-hotlist {target} {
893 set olen [llength $hotTargets]
895 foreach e $hotTargets {
896 if {$target == [lindex $e 0]} {
897 set hotTargets [lreplace $hotTargets $i $i]
901 set-target-hotlist $olen
904 proc set-target-hotlist {olen} {
909 .top.target.m delete 7 [expr 7+$olen]
911 .top.target.m delete 6 [expr 6+$olen]
915 foreach e $hotTargets {
916 set target [lindex $e 0]
917 set base [lindex $e 1]
919 .top.target.m add command -label "$i $target" -command \
920 [list reopen-target $target {}]
922 .top.target.m add command -label "$i $target - $base" -command \
923 [list reopen-target $target $base]
932 proc reopen-target {target base} {
934 open-target $target $base
935 update-target-hotlist $target $base
938 proc define-target-action {} {
941 set target [.target-define.top.target.entry get]
945 foreach n [array names profile] {
947 destroy .target-define
952 set seq [lindex $profile(Default) 12]
954 dputs $profile(Default)
955 set profile($target) $profile(Default)
956 set profile(Default) [lreplace $profile(Default) 12 12 [incr seq]]
958 protocol-setup $target
959 destroy .target-define
962 proc fail-response {target} {
963 set c [lindex [z39 failInfo] 0]
964 set m [lindex [z39 failInfo] 1]
969 proc connect-response {target base} {
970 dputs "connect-response"
971 show-target $target $base
975 proc open-target {target base} {
981 z39 comstack [lindex $profile($target) 6]
982 z39 protocol [lindex $profile($target) 11]
983 z39 idAuthentication [lindex $profile($target) 3]
984 z39 maximumRecordSize [lindex $profile($target) 4]
985 z39 preferredMessageSize [lindex $profile($target) 5]
986 dputs "maximumRecordSize="
987 dputs [z39 maximumRecordSize]
988 dputs "preferredMessageSize="
989 dputs [z39 preferredMessageSize]
990 show-status Connecting 1 0
992 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
994 z39 databaseNames $base
996 set x [lindex $profile($target) 13]
1000 z39 largeSetLowerBound $x
1002 set x [lindex $profile($target) 14]
1006 z39 smallSetUpperBound $x
1008 set x [lindex $profile($target) 15]
1012 z39 mediumSetPresentNumber $x
1014 set presentChunk [lindex $profile($target) 16]
1015 if {$presentChunk == ""} {
1019 z39 failback [list fail-response $target]
1020 z39 callback [list connect-response $target $base]
1023 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
1026 tkerror $errorMessage
1027 show-status "Not connected" 0 {}
1031 configure-disable-e .top.target.m 0
1032 configure-enable-e .top.target.m 1
1033 configure-enable-e .top.target.m 2
1036 proc close-target {} {
1045 .bot.a.set configure -text ""
1049 show-status {Not connected} 0 0
1052 configure-disable-e .top.target.m 1
1053 configure-disable-e .top.target.m 2
1055 .top.rset.m delete 2 last
1057 .top.rset.m delete 1 last
1059 .top.rset.m add separator
1060 configure-enable-e .top.target.m 0
1063 proc load-set-action {} {
1067 ir-set z39.$setNoLast z39
1069 set fname [.load-set.top.filename.entry get]
1072 show-status Loading 1 {}
1074 z39.$setNoLast loadFile $fname
1076 set no [z39.$setNoLast numberOfRecordsReturned]
1077 add-title-lines $setNoLast $no 1
1079 set l [format "%-4d %7d" $setNoLast $no]
1080 .top.rset.m add command -label $l \
1081 -command [list add-title-lines $setNoLast 10000 1]
1082 show-status Ready 0 {}
1088 set oldFocus [focus]
1092 frame $w.top.filename
1093 pack $w.top.filename -side top -anchor e -pady 2
1095 entry-fields $w.top {filename} \
1097 {load-set-action} {destroy .load-set}
1099 top-down-ok-cancel $w {load-set-action} 1
1103 proc init-request {} {
1110 z39 callback {init-response}
1111 show-status Initializing 1 {}
1112 set err [catch {z39 init} errorMessage]
1114 tkerror $errorMessage
1115 show-status Ready 0 {}
1119 proc init-response {} {
1123 dputs {init-reponse}
1128 if {![z39 initResult]} {
1129 show-status Ready 0 1
1130 set u [z39 userInformationField]
1132 tkerror "Connection rejected by target: $u"
1134 if {[lsearch [z39 options] scan] >= 0} {
1139 show-status Ready 0 1
1143 proc search-request {bflag} {
1152 global elementSetNames
1156 if {[z39 connect] == ""} {
1159 dputs "search-request"
1161 if {!$bflag && $busy} {
1162 dputs "busy: search-request ignored"
1167 show-status Searching 1 0
1168 set delayRequest {search-request 1}
1173 set query [index-query]
1178 set setNo $setNoLast
1179 ir-set z39.$setNo z39
1181 if {[lindex $profile($target) 10] == 1} {
1182 z39.$setNo setName $setNo
1183 dputs "setName=${setNo}"
1185 z39.$setNo setName Default
1186 dputs "setName=Default"
1188 if {[lindex $profile($target) 8] == 1} {
1189 z39.$setNo queryType rpn
1191 if {[lindex $profile($target) 9] == 1} {
1192 z39.$setNo queryType ccl
1196 if {$recordSyntax == "None" } {
1197 z39.$setNo preferredRecordSyntax {}
1199 z39.$setNo preferredRecordSyntax $recordSyntax
1201 if {$elementSetNames == "None" } {
1202 z39.$setNo elementSetNames {}
1203 z39.$setNo smallSetElementSetNames {}
1204 z39.$setNo mediumSetElementSetNames {}
1206 z39.$setNo elementSetNames $elementSetNames
1207 z39.$setNo smallSetElementSetNames $elementSetNames
1208 z39.$setNo mediumSetElementSetNames $elementSetNames
1210 z39 callback {search-response}
1211 z39.$setNo search $query
1212 show-status Searching 1 0
1215 proc scan-copy {y entry} {
1217 set no [$w.top.list nearest $y]
1219 .lines.$entry.e delete 0 end
1220 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
1223 proc scan-request {} {
1230 global curIndexEntry
1231 global queryButtonsFind
1232 global queryInfoFind
1236 dputs "scan-request"
1239 show-status Scanning 1 0
1240 set delayRequest scan-request
1249 set b [lindex $queryButtonsFind $curIndexEntry]
1251 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
1252 set attr "@attr $a $attr"
1254 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
1255 ir-scan z39.scan z39
1257 if {![winfo exists $w]} {
1264 entry $w.top.entry -relief sunken
1265 pack $w.top.entry -fill x -padx 4 -pady 2
1266 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
1267 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
1269 scrollbar $w.top.scroll -orient vertical -border 1
1270 pack $w.top.list -side left -fill both -expand yes
1271 pack $w.top.scroll -side right -fill y
1272 $w.top.scroll config -command [list $w.top.list yview]
1274 bottom-buttons $w [list {Close} [list destroy $w] \
1275 {Up} [list scan-up $attr] \
1276 {Down} [list scan-down $attr]] 0
1277 bind $w.top.list <Up> [list scan-up $attr]
1278 bind $w.top.list <Down> [list scan-down $attr]
1281 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
1282 wm title $w "Scan $title"
1284 z39 callback [list scan-response $attr 0 35]
1285 z39.scan numberOfTermsRequested 5
1286 z39.scan preferredPositionInResponse 1
1287 z39.scan scan "${attr} 0"
1289 show-status Scanning 1 0
1292 proc scan-term-h {attr} {
1300 set nScanTerm [$w.top.entry get]
1301 if {$nScanTerm == $scanTerm} {
1304 set scanTerm $nScanTerm
1305 z39 callback [list scan-response $attr 0 35]
1306 z39.scan numberOfTermsRequested 5
1307 z39.scan preferredPositionInResponse 1
1308 dputs "${attr} \{${scanTerm}\}"
1309 if {$scanTerm == ""} {
1310 z39.scan scan "${attr} 0"
1312 z39.scan scan "${attr} \{${scanTerm}\}"
1314 show-status Scanning 1 0
1317 proc scan-response {attr start toget} {
1324 dputs "In scan-response"
1325 set m [z39.scan numberOfEntriesReturned]
1331 if {![winfo exists .scan-window]} {
1334 dputs "Handling cancel"
1335 if {$delayRequest != ""} {
1340 show-status Ready 0 1
1343 set nScanTerm [$w.top.entry get]
1344 if {$nScanTerm != $scanTerm} {
1345 z39 callback [list scan-response $attr 0 35]
1346 z39.scan numberOfTermsRequested 5
1347 z39.scan preferredPositionInResponse 1
1348 set scanTerm $nScanTerm
1349 dputs "${attr} \{${scanTerm}\}"
1350 if {$scanTerm == ""} {
1351 z39.scan scan "${attr} 0"
1353 z39.scan scan "${attr} \{${scanTerm}\}"
1355 show-status Scanning 1 0
1358 set status [z39.scan scanStatus]
1361 show-status Ready 0 1
1366 for {set i 0} {$i < $m} {incr i} {
1367 set term [lindex [z39.scan scanLine $i] 1]
1368 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1369 $w.top.list insert $i "$nostr $term"
1372 $w.top.list yview $scanView
1374 $w.top.list delete $start end
1375 for {set i 0} {$i < $m} {incr i} {
1376 set term [lindex [z39.scan scanLine $i] 1]
1377 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1378 $w.top.list insert end "$nostr $term"
1382 dputs "Handling cancel"
1384 if {$delayRequest != ""} {
1390 if {$toget > 0 && $m > 1 && $m < $toget} {
1391 set ntoget [expr $toget - $m + 1]
1392 dputs ntoget=$ntoget
1393 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1395 dputs "down continue: $q"
1397 z39.scan numberOfTermsRequested 10
1399 z39.scan numberOfTermsRequested $ntoget
1401 z39.scan preferredPositionInResponse 1
1402 dputs "${attr} \{$q\}"
1403 z39.scan scan "${attr} \{$q\}"
1406 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1407 set ntoget [expr - $toget - $m]
1408 dputs ntoget=$ntoget
1409 z39 callback [list scan-response $attr 0 -$ntoget]
1410 set q [string range [$w.top.list get 0] 8 end]
1411 dputs "up continue: $q"
1413 z39.scan numberOfTermsRequested 10
1414 z39.scan preferredPositionInResponse 11
1416 z39.scan numberOfTermsRequested $ntoget
1417 z39.scan preferredPositionInResponse [incr ntoget]
1419 dputs "${attr} \{$q\}"
1420 z39.scan scan "${attr} \{$q\}"
1423 show-status Ready 0 1
1426 proc scan-down {attr} {
1434 show-status {Scanning down} 1 0
1435 set delayRequest [list scan-down $attr]
1441 set scanView [expr $scanView + 5]
1442 set s [$w.top.list size]
1443 if {$scanView > $s} {
1444 z39 callback [list scan-response $attr [expr $s - 1] 25]
1445 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1447 z39.scan numberOfTermsRequested 10
1448 z39.scan preferredPositionInResponse 1
1449 show-status Scanning 1 0
1450 dputs "${attr} \{$q\}"
1451 z39.scan scan "${attr} \{$q\}"
1454 $w.top.list yview $scanView
1457 proc scan-up {attr} {
1465 show-status Scanning 1 0
1466 set delayRequest [list scan-up $attr]
1472 set scanView [expr $scanView - 5]
1473 if {$scanView < 0} {
1474 z39 callback [list scan-response $attr 0 -25]
1475 set q [string range [$w.top.list get 0] 8 end]
1477 z39.scan numberOfTermsRequested 10
1478 z39.scan preferredPositionInResponse 11
1479 show-status Scanning 1 0
1480 z39.scan scan "${attr} \{$q\}"
1483 $w.top.list yview $scanView
1486 proc search-response {} {
1496 dputs "In search-response"
1498 dputs "Handling cancel"
1500 if {$delayRequest != ""} {
1508 set setMax [z39.$setNo resultCount]
1509 show-status Ready 0 1
1510 set status [z39.$setNo responseStatus]
1511 if {[lindex $status 0] == "NSD"} {
1512 z39.$setNo nextResultSetPosition 0
1513 set code [lindex $status 1]
1514 set msg [lindex $status 2]
1515 set addinfo [lindex $status 3]
1516 tkerror "NSD$code: $msg: $addinfo"
1519 show-message "${setMax} hits"
1524 show-status Ready 0 1
1525 set l [format "%-4d %7d" $setNo $setMax]
1526 .top.rset.m add command -label $l \
1527 -command [list add-title-lines $setNo 10000 1]
1531 set no [z39.$setNo numberOfRecordsReturned]
1532 dputs "Returned $no records, setOffset $setOffset"
1533 add-title-lines $setNo $no $setOffset
1534 set setOffset [expr $setOffset + $no]
1536 set toGet [expr $setMax - $setOffset + 1]
1538 if {$setOffset == 1} {
1540 } elseif {$toGet > $presentChunk} {
1541 set toGet $presentChunk
1543 z39 callback {present-response}
1544 z39.$setNo present $setOffset $toGet
1545 show-status Retrieving 1 0
1549 proc present-more {number} {
1558 dputs "present-more"
1560 show-status Retrieving 1 0
1561 set delayRequest "present-more $number"
1567 dputs "setNo=$setNo"
1570 set setOffset [z39.$setNo nextResultSetPosition]
1571 dputs "setOffest=${setOffset}"
1572 dputs "setNo=${setNo}"
1573 set max [z39.$setNo resultCount]
1574 if {$max < $setOffset} {
1576 dputs "setOffset=$setOffset"
1577 show-status Ready 0 1
1580 if {$number == ""} {
1584 if {$setMax > $max} {
1588 z39 callback {present-response}
1590 set toGet [expr $setMax - $setOffset + 1]
1594 if {$toGet > $presentChunk} {
1595 set toGet $presentChunk
1597 z39.$setNo present $setOffset $toGet
1598 show-status Retrieving 1 0
1601 proc init-title-lines {} {
1602 .data.record delete 0.0 end
1605 proc add-title-lines {setno no offset} {
1606 global displayFormats
1607 global displayFormat
1611 dputs "add-title-lines offset=${offset} no=${no}"
1619 .bot.a.set configure -text $setno
1620 .data.record delete 0.0 end
1622 set ffunc [lindex $displayFormats $displayFormat]
1623 dputs "ffunc=$ffunc"
1624 set ffunc "display-$ffunc"
1625 for {set i 0} {$i < $no} {incr i} {
1626 set o [expr $i + $offset]
1627 set type [z39.$setno type $o]
1629 dputs "no more at $o"
1632 .data.record tag bind r$o <Any-Enter> {}
1633 .data.record tag bind r$o <Any-Leave> {}
1634 set insert0 [.data.record index insert]
1635 $ffunc $setno $o .data.record 1
1636 .data.record tag add r$o $insert0 insert
1637 .data.record tag bind r$o <1> \
1638 [list popup-marc $setno $o 0 0]
1642 show-status Ready 0 1
1646 proc present-response {} {
1654 dputs "In present-response"
1655 set no [z39.$setNo numberOfRecordsReturned]
1656 dputs "Returned $no records, setOffset $setOffset"
1657 add-title-lines $setNo $no $setOffset
1658 set setOffset [expr $setOffset + $no]
1660 dputs "Handling cancel"
1662 if {$delayRequest != ""} {
1667 set status [z39.$setNo responseStatus]
1668 if {[lindex $status 0] == "NSD"} {
1669 show-status Ready 0 1
1670 set code [lindex $status 1]
1671 set msg [lindex $status 2]
1672 set addinfo [lindex $status 3]
1673 tkerror "NSD$code: $msg: $addinfo"
1676 if {$no > 0 && $setOffset <= $setMax} {
1677 dputs "present-request from ${setOffset}"
1678 set toGet [expr $setMax - $setOffset + 1]
1679 if {$toGet > $presentChunk} {
1680 set toGet $presentChunk
1682 z39.$setNo present $setOffset $toGet
1684 show-status Ready 0 1
1688 proc left-cursor {w} {
1689 set i [$w index insert]
1697 proc right-cursor {w} {
1698 set i [$w index insert]
1704 proc bind-fields {list returnAction escapeAction} {
1705 set max [expr [llength $list]-1]
1706 for {set i 0} {$i < $max} {incr i} {
1707 bind [lindex $list $i] <Return> $returnAction
1708 bind [lindex $list $i] <Escape> $escapeAction
1710 bind [lindex $list $i] <Tab> \
1711 [list focus [lindex $list [expr $i+1]]]
1712 bind [lindex $list $i] <Left> \
1713 [list left-cursor [lindex $list $i]]
1714 bind [lindex $list $i] <Right> \
1715 [list right-cursor [lindex $list $i]]
1718 bind [lindex $list $i] <Return> $returnAction
1719 bind [lindex $list $i] <Escape> $escapeAction
1721 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1722 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1723 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1725 focus [lindex $list 0]
1728 proc entry-fields {parent list tlist returnAction escapeAction} {
1731 foreach field $list {
1732 set label ${parent}.${field}.label
1733 set entry ${parent}.${field}.entry
1734 label $label -text [lindex $tlist $i] -anchor e
1735 entry $entry -width 32 -relief sunken
1736 pack $label -side left
1737 pack $entry -side right
1738 lappend alist $entry
1741 bind-fields $alist $returnAction $escapeAction
1744 proc define-target-dialog {} {
1745 set w .target-define
1751 pack $w.top.target \
1752 -side top -anchor e -pady 2
1753 entry-fields $w.top {target} \
1755 {define-target-action} {destroy .target-define}
1756 top-down-ok-cancel $w {define-target-action} 1
1759 proc protocol-setup-delete {target w} {
1761 global settingsChanged
1763 set a [alert "Are you sure you want to delete the target \
1764 definition $target ?"]
1767 unset profile($target)
1768 set settingsChanged 1
1770 delete-target-hotlist $target
1774 proc protocol-setup-action {target w} {
1776 global settingsChanged
1780 set settingsChanged 1
1781 set len [$w.top.databases.list size]
1782 for {set i 0} {$i < $len} {incr i} {
1783 lappend dataBases [$w.top.databases.list get $i]
1785 set wno [lindex $profile($target) 12]
1787 set profile($target) [list [$w.top.description.entry get] \
1788 [$w.top.host.entry get] \
1789 [$w.top.port.entry get] \
1790 [$w.top.idAuthentication.entry get] \
1791 $targetS($target,MRS) \
1792 $targetS($target,PMS) \
1793 $targetS($target,csType) \
1795 $targetS($target,RPN) \
1796 $targetS($target,CCL) \
1797 $targetS($target,ResultSets) \
1798 $targetS($target,protocolType) \
1800 $targetS($target,LSLB) \
1801 $targetS($target,SSUB) \
1802 $targetS($target,MSPN) \
1803 $targetS($target,presentChunk) ]
1806 delete-target-hotlist $target
1807 dputs $profile($target)
1811 proc place-force {window parent} {
1812 set g [wm geometry $parent]
1814 set p1 [string first + $g]
1815 set p2 [string last + $g]
1817 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1818 set y [expr 60+[string range $g [expr $p2 +1] end]]
1819 wm geometry $window +${x}+${y}
1822 proc add-database-action {target w} {
1825 $w.top.databases.list insert end \
1826 [.database-select.top.database.entry get]
1827 destroy .database-select
1830 proc add-database {target wp} {
1833 set w .database-select
1835 set oldFocus [focus]
1841 frame $w.top.database
1843 pack $w.top.database -side top -anchor e -pady 2
1845 entry-fields $w.top {database} \
1846 {{Database to add:}} \
1847 [list add-database-action $target $wp] {destroy .database-select}
1849 top-down-ok-cancel $w [list add-database-action $target $wp] 1
1853 proc delete-database {target w} {
1857 foreach i [$w.top.databases.list curselection] {
1858 set b [$w.top.databases.list get $i]
1861 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1863 foreach i [lsort -decreasing \
1864 [$w.top.databases.list curselection]] {
1865 $w.top.databases.list delete $i
1870 proc protocol-setup {target} {
1875 while {[winfo exists .setup-$bno]} {
1882 wm title $w "Setup $target"
1886 if {$target == ""} {
1890 dputs $profile($target)
1892 frame $w.top.description
1895 frame $w.top.idAuthentication
1896 frame $w.top.cs-type -relief ridge -border 2
1897 frame $w.top.protocol -relief ridge -border 2
1898 frame $w.top.query -relief ridge -border 2
1899 frame $w.top.databases -relief ridge -border 2
1901 # Maximum/preferred/idAuth ...
1902 pack $w.top.description $w.top.host $w.top.port \
1903 $w.top.idAuthentication -side top -anchor e -pady 2
1905 entry-fields $w.top {description host port idAuthentication } \
1906 {{Description:} {Host:} {Port:} {Id Authentication:}} \
1907 [list protocol-setup-action $target $w] [list destroy $w]
1909 foreach sub {description host port idAuthentication} {
1911 bind $w.top.$sub.entry <Control-a> [list add-database $target $w]
1912 bind $w.top.$sub.entry <Control-d> [list delete-database $target $w]
1914 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1915 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1916 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1917 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1918 set targetS($target,csType) [lindex $profile($target) 6]
1919 set targetS($target,RPN) [lindex $profile($target) 8]
1920 set targetS($target,CCL) [lindex $profile($target) 9]
1921 set targetS($target,ResultSets) [lindex $profile($target) 10]
1922 set targetS($target,protocolType) [lindex $profile($target) 11]
1923 if {$targetS($target,protocolType) == ""} {
1924 set targetS($target,protocolType) Z39
1926 set targetS($target,LSLB) [lindex $profile($target) 13]
1927 set targetS($target,SSUB) [lindex $profile($target) 14]
1928 set targetS($target,MSPN) [lindex $profile($target) 15]
1929 set targetS($target,presentChunk) [lindex $profile($target) 16]
1930 set targetS($target,MRS) [lindex $profile($target) 4]
1931 set targetS($target,PMS) [lindex $profile($target) 5]
1933 pack $w.top.databases -side left -pady 2 -padx 2 -expand yes -fill both
1935 label $w.top.databases.label -text "Databases"
1936 button $w.top.databases.add -text Add \
1937 -command [list add-database $target $w]
1938 button $w.top.databases.delete -text Delete \
1939 -command [list delete-database $target $w]
1941 listbox $w.top.databases.list -geometry 14x6 \
1942 -yscrollcommand "$w.top.databases.scroll set"
1944 listbox $w.top.databases.list -width 14 -height 5\
1945 -yscrollcommand "$w.top.databases.scroll set"
1947 scrollbar $w.top.databases.scroll -orient vertical -border 1
1948 pack $w.top.databases.label -side top -fill x \
1950 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1952 pack $w.top.databases.list -side left -fill both -expand yes \
1954 pack $w.top.databases.scroll -side right -fill y \
1956 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1958 foreach b [lindex $profile($target) 7] {
1959 $w.top.databases.list insert end $b
1963 pack $w.top.cs-type -pady 2 -padx 2 -side top -fill x
1965 label $w.top.cs-type.label -text "Transport"
1966 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1967 -variable targetS($target,csType) -value tcpip
1968 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1969 -variable targetS($target,csType) -value mosi
1971 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1972 -padx 2 -side top -fill x
1975 pack $w.top.protocol -pady 2 -padx 2 -side top -fill x
1977 label $w.top.protocol.label -text "Protocol"
1978 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1979 -variable targetS($target,protocolType) -value Z39
1980 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1981 -variable targetS($target,protocolType) -value SR
1983 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1984 -padx 2 -side top -fill x
1987 pack $w.top.query -pady 2 -padx 2 -side top -fill x
1989 label $w.top.query.label -text "Query support"
1990 checkbutton $w.top.query.c1 -text "RPN query" -anchor w \
1991 -variable targetS($target,RPN)
1992 checkbutton $w.top.query.c2 -text "CCL query" -anchor w \
1993 -variable targetS($target,CCL)
1994 checkbutton $w.top.query.c3 -text "Result sets" -anchor w \
1995 -variable targetS($target,ResultSets)
1997 pack $w.top.query.label -side top
1998 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
1999 -padx 2 -side top -fill x
2002 bottom-buttons $w [list {Ok} [list protocol-setup-action $target $w] \
2003 {Delete} [list protocol-setup-delete $target $w] \
2004 {Advanced} [list advanced-setup $target $bno] \
2005 {Cancel} [list destroy $w]] 0
2009 proc advanced-setup {target b} {
2013 set w .advanced-setup-$b
2017 wm title $w "Advanced setup $target"
2021 if {$target == ""} {
2026 frame $w.top.largeSetLowerBound
2027 frame $w.top.smallSetUpperBound
2028 frame $w.top.mediumSetPresentNumber
2029 frame $w.top.presentChunk
2030 frame $w.top.maximumRecordSize
2031 frame $w.top.preferredMessageSize
2033 pack $w.top.largeSetLowerBound $w.top.smallSetUpperBound \
2034 $w.top.mediumSetPresentNumber $w.top.presentChunk \
2035 $w.top.maximumRecordSize $w.top.preferredMessageSize \
2036 -side top -anchor e -pady 2
2038 entry-fields $w.top {largeSetLowerBound smallSetUpperBound \
2039 mediumSetPresentNumber presentChunk maximumRecordSize \
2040 preferredMessageSize} \
2041 {{Large Set Lower Bound:} {Small Set Upper Bound:} \
2042 {Medium Set Present Number:} {Present Chunk:} \
2043 {Maximum Record Size:} {Preferred Message Size:}} \
2044 [list advanced-setup-action $target $b] [list destroy $w]
2046 $w.top.largeSetLowerBound.entry insert 0 $targetS($target,LSLB)
2047 $w.top.smallSetUpperBound.entry insert 0 $targetS($target,SSUB)
2048 $w.top.mediumSetPresentNumber.entry insert 0 $targetS($target,MSPN)
2049 $w.top.presentChunk.entry insert 0 $targetS($target,presentChunk)
2050 $w.top.maximumRecordSize.entry insert 0 $targetS($target,MRS)
2051 $w.top.preferredMessageSize.entry insert 0 $targetS($target,PMS)
2053 bottom-buttons $w [list {Ok} [list advanced-setup-action $target $b] \
2054 {Cancel} [list destroy $w]] 0
2057 proc advanced-setup-action {target b} {
2058 set w .advanced-setup-$b
2061 set targetS($target,LSLB) [$w.top.largeSetLowerBound.entry get]
2062 set targetS($target,SSUB) [$w.top.smallSetUpperBound.entry get]
2063 set targetS($target,MSPN) [$w.top.mediumSetPresentNumber.entry get]
2064 set targetS($target,presentChunk) [$w.top.presentChunk.entry get]
2065 set targetS($target,MRS) [$w.top.maximumRecordSize.entry get]
2066 set targetS($target,PMS) [$w.top.preferredMessageSize.entry get]
2068 dputs "advanced-setup-action"
2072 proc database-select-action {} {
2073 set w .database-select.top
2075 foreach indx [$w.databases.list curselection] {
2076 lappend b [$w.databases.list get $indx]
2079 z39 databaseNames $b
2081 destroy .database-select
2084 proc database-select {} {
2085 set w .database-select
2090 set oldFocus [focus]
2095 frame $w.top.databases -relief ridge -border 2
2097 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
2099 label $w.top.databases.label -text "List"
2100 listbox $w.top.databases.list -width 20 -height 6 \
2101 -yscrollcommand "$w.top.databases.scroll set"
2102 scrollbar $w.top.databases.scroll -orient vertical -border 1
2103 pack $w.top.databases.label -side top -fill x \
2105 pack $w.top.databases.list -side left -fill both -expand yes \
2107 pack $w.top.databases.scroll -side right -fill y \
2109 $w.top.databases.scroll config -command "$w.top.databases.list yview"
2111 foreach b [lindex $profile($hostid) 7] {
2112 $w.top.databases.list insert end $b
2114 top-down-ok-cancel $w {database-select-action} 1
2118 proc cascade-target-list {} {
2121 foreach sub [winfo children .top.target.m.clist] {
2124 .top.target.m.clist delete 0 last
2125 foreach n [lsort [array names profile]] {
2126 if {$n != "Default"} {
2127 set nl [lindex $profile($n) 12]
2128 if {[llength [lindex $profile($n) 7]] > 1} {
2129 .top.target.m.clist add cascade -label $n \
2130 -menu .top.target.m.clist.$nl
2131 menu .top.target.m.clist.$nl
2132 foreach b [lindex $profile($n) 7] {
2133 .top.target.m.clist.$nl add command -label $b \
2134 -command [list reopen-target $n $b]
2137 .top.target.m.clist add command -label $n \
2138 -command [list reopen-target $n {}]
2142 .top.target.m.slist delete 0 last
2143 foreach n [lsort [array names profile]] {
2144 .top.target.m.slist add command -label $n \
2145 -command [list protocol-setup $n]
2149 proc query-select {i} {
2150 global queryButtonsFind
2151 global queryInfoFind
2155 set queryInfoFind [lindex $queryInfo $i]
2156 set queryButtonsFind [lindex $queryButtons $i]
2158 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2161 proc query-new-action {} {
2165 global settingsChanged
2167 set settingsChanged 1
2168 lappend queryTypes [.query-new.top.index.entry get]
2169 lappend queryButtons {}
2170 lappend queryInfo {}
2180 set oldFocus [focus]
2185 -side top -anchor e -pady 2
2186 entry-fields $w.top index \
2188 query-new-action {destroy .query-new}
2189 top-down-ok-cancel $w query-new-action 1
2193 proc query-delete-action {queryNo} {
2197 global settingsChanged
2199 set settingsChanged 1
2201 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
2202 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
2203 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
2204 destroy .query-delete
2208 proc query-delete {queryNo} {
2216 set n [lindex $queryTypes $queryNo]
2218 label $w.top.warning -bitmap warning
2219 message $w.top.quest -text "Are you sure you want to delete the \
2220 query type $n ?" -aspect 300
2221 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
2222 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
2223 {Cancel} [list destroy $w]] 1
2226 proc cascade-query-list {} {
2228 set w .top.options.m.query
2231 $w.slist delete 0 last
2232 foreach n $queryTypes {
2233 $w.slist add command -label $n -command [list query-setup $i]
2238 $w.clist delete 0 last
2239 foreach n $queryTypes {
2240 $w.clist add command -label $n -command [list query-select $i]
2244 $w.dlist delete 0 last
2245 foreach n $queryTypes {
2246 $w.dlist add command -label $n -command [list query-delete $i]
2251 proc save-geometry {} {
2252 global windowGeometry
2255 global displayFormat
2258 global elementSetNames
2261 set windowGeometry(.) [wm geometry .]
2263 if {[catch {set f [open ~/.clientrc.tcl w]}]} {
2266 if {$hostid != "Default"} {
2267 puts $f "set hostid $hostid"
2268 set b [z39 databaseNames]
2269 puts $f "set hostbase $b"
2271 puts $f "set hotTargets \{ $hotTargets \}"
2272 puts $f "set textWrap $textWrap"
2273 puts $f "set displayFormat $displayFormat"
2274 puts $f "set popupMarcdf $popupMarcdf"
2275 puts $f "set recordSyntax $recordSyntax"
2276 puts $f "set elementSetNames $elementSetNames"
2277 foreach n [array names windowGeometry] {
2278 puts -nonewline $f "set \{windowGeometry($n)\} \{"
2279 puts -nonewline $f $windowGeometry($n)
2285 proc save-settings {} {
2288 global settingsChanged
2293 if {![file writable "${libdir}/clientrc.tcl"]} {
2294 set a [alert "Cannot open ${libdir}/clientrc.tcl for writing. Do you \
2295 wish to save clientrc.tcl in the current directory instead?"]
2299 set f [open "clientrc.tcl" w]
2301 set f [open "${libdir}/clientrc.tcl" w]
2303 puts $f "# Setup file"
2305 foreach n [array names profile] {
2306 puts -nonewline $f "set \{profile($n)\} \{"
2307 puts -nonewline $f $profile($n)
2310 puts -nonewline $f "set queryTypes \{"
2311 puts -nonewline $f $queryTypes
2314 puts -nonewline $f "set queryButtons \{"
2315 puts -nonewline $f $queryButtons
2318 puts -nonewline $f "set queryInfo \{"
2319 puts -nonewline $f $queryInfo
2322 set settingsChanged 0
2331 set oldFocus [focus]
2335 label $w.top.warning -bitmap warning
2336 message $w.top.message -text $ask -aspect 300 \
2337 -font -Adobe-Times-Medium-R-Normal-*-180-*
2339 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
2342 top-down-ok-cancel $w {alert-action} 1
2347 proc alert-action {} {
2353 proc exit-action {} {
2354 global settingsChanged
2356 if {$settingsChanged} {
2357 set a [alert "you haven't saved your settings. Do you wish to save?"]
2366 proc listbuttonaction {w name h user i} {
2367 $w configure -text [lindex $name 0]
2368 $h [lindex $name 1] $user $i
2371 proc listbuttonx {button no names handle user} {
2372 if {[winfo exists $button]} {
2373 $button configure -text [lindex [lindex $names $no] 0]
2374 ${button}.m delete 0 last
2376 menubutton $button -text [lindex [lindex $names $no] 0] \
2377 -width 10 -menu ${button}.m -relief raised -border 1
2381 foreach name $names {
2382 ${button}.m add command -label [lindex $name 0] \
2383 -command [list listbuttonaction ${button} $name \
2389 proc listbutton {button no names} {
2390 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
2391 -relief raised -border 1
2393 foreach name $names {
2394 ${button}.m add command -label $name \
2395 -command [list ${button} configure -text $name]
2399 proc listbuttonv-action {button var names i} {
2402 set $var [lindex $names [expr $i+1]]
2403 $button configure -text [lindex $names $i]
2406 proc listbuttonv {button var names} {
2410 eval "set val $$var"
2411 set l [llength $names]
2412 for {set i 1} {$i < $l} {incr i 2} {
2413 if {$val == [lindex $names $i]} {
2415 set n [lindex $names $i]
2419 if {[winfo exists $button]} {
2420 $button configure -text $n
2423 menubutton $button -text $n -menu ${button}.m \
2424 -relief raised -border 1
2426 for {set i 0} {$i < $l} {incr i 2} {
2427 ${button}.m add command -label [lindex $names $i] \
2428 -command [list listbuttonv-action $button $var $names $i]
2432 proc query-add-index-action {queryNo} {
2436 global queryButtonsTmp
2438 set newI [.query-add-index.top.index.entry get]
2439 lappend queryInfoTmp [list $newI {}]
2440 $w.top.index.list insert end $newI
2441 destroy .query-add-index
2442 #destroy $w.top.lines
2443 #frame $w.top.lines -relief ridge -border 2
2444 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2445 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2448 proc query-add-line {queryNo} {
2452 global queryButtonsTmp
2454 lappend queryButtonsTmp {I 0}
2456 #destroy $w.top.lines
2457 #frame $w.top.lines -relief ridge -border 2
2458 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2459 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2462 proc query-del-line {queryNo} {
2466 global queryButtonsTmp
2468 set l [llength $queryButtonsTmp]
2473 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
2474 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2477 proc query-add-index {queryNo} {
2478 set w .query-add-index
2481 set oldFocus [focus]
2482 place-force $w .query-setup
2486 -side top -anchor e -pady 2
2487 entry-fields $w.top {index} \
2489 [list query-add-index-action $queryNo] [list destroy $w]
2490 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
2494 proc query-setup-action {queryNo} {
2497 global queryButtonsTmp
2499 global queryButtonsFind
2500 global queryInfoFind
2502 global settingsChanged
2504 set settingsChanged 1
2506 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
2508 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
2510 set queryInfoFind $queryInfoTmp
2511 set queryButtonsFind $queryButtonsTmp
2513 destroy .query-setup
2514 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2517 proc activate-e-index {value no i} {
2518 global queryButtonsTmp
2519 global queryIndexTmp
2521 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
2522 dputs $queryButtonsTmp
2523 set queryIndexTmp $i
2526 proc activate-index {value no i} {
2527 global queryButtonsFind
2529 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
2531 dputs "queryButtonsFind $queryButtonsFind"
2534 proc update-attr {} {
2536 listbuttonv $w.top.relation.b relationTmpValue\
2537 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
2538 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
2539 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
2540 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
2541 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
2542 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
2543 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
2544 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
2545 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
2546 {local-number} 107 {string} 108 {numeric string} 109}
2547 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2548 {Left} 2 {Left and right} 3 {No truncation} 100 \
2549 {Process #} 101 {Re-1} 102 {Re-2} 103}
2550 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2551 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2554 proc use-attr {init} {
2566 {BNB card number} 10
2567 {BGF(sic) number} 11
2569 {Dewey classification} 13
2570 {UDC classification} 14
2571 {Bliss classification} 15
2573 {NLM call number} 17
2574 {NAL call number} 18
2575 {MOS call number} 19
2576 {Local classification} 20
2577 {Subject heading} 21
2579 {BDI-index-subject} 23
2583 {LC-subject-heading} 27
2584 {RVM-subject-heading} 28
2585 {Local subject index} 29
2587 {Date of publication} 31
2588 {Date of acquisition} 32
2590 {Title-collective} 34
2593 {Title-added-title-page} 37
2597 {Title-other-variant} 41
2599 {Title-abbreviated} 43
2603 {Subject-subdivision} 47
2604 {Number-natl-bibliography} 48
2605 {Number-legal-deposit} 49
2606 {Number-govt-publication} 50
2607 {Number-publisher-for-music} 51
2609 {Number-local-call} 53
2611 {Code-geographic-area} 55
2612 {Code-institution} 56
2614 {Name-geographic} 58
2615 {Place-publication} 59
2617 {Microform-generation} 61
2624 {Author-name-personal} 1004
2625 {Author-name-corporate} 1005
2626 {Author-name-conference} 1006
2627 {Identifier-standard} 1007
2628 {Subject-LC-children's} 1008
2629 {Subject-name-personal} 1009
2631 {Date/time added to database} 1011
2632 {Date/time last modified} 1012
2633 {Authority/format identifier} 1013
2635 {Concept-reference} 1015
2637 {Server choice} 1017
2639 {Record source} 1019
2642 {Geographic class} 1022
2646 {Related periodical} 1026
2647 {Report number} 1027
2649 {Thematic number} 1030
2650 {Material type} 1031
2658 set l [llength $attr]
2663 for {set i 0} {$i < $l} {incr i} {
2664 $w.top.use.list insert end [lindex $attr $i]
2666 if {$useTmpValue == [lindex $attr $i]} {
2672 $w.top.use.list selection clear 0 end
2673 $w.top.use.list selection set $s $s
2675 $w.top.use.list select from $s
2676 $w.top.use.list select to $s
2682 $w.top.use.list yview $s
2684 set lno [lindex [$w.top.use.list curselection] 0]
2685 set i [expr $lno+$lno+1]
2686 set useTmpValue [lindex $attr $i]
2687 dputs "useTmpValue=$useTmpValue"
2691 proc index-setup-action {oldAttr queryNo indexNo} {
2692 set attr [lindex $oldAttr 0]
2695 global relationTmpValue
2696 global structureTmpValue
2697 global truncationTmpValue
2698 global completenessTmpValue
2699 global positionTmpValue
2704 dputs "index-setup-action"
2705 dputs "queryNo $queryNo"
2706 dputs "indexNo $indexNo"
2707 if {$useTmpValue > 0} {
2708 lappend attr "1=$useTmpValue"
2710 if {$relationTmpValue > 0} {
2711 lappend attr "2=$relationTmpValue"
2713 if {$positionTmpValue > 0} {
2714 lappend attr "3=$positionTmpValue"
2716 if {$structureTmpValue > 0} {
2717 lappend attr "4=$structureTmpValue"
2719 if {$truncationTmpValue > 0} {
2720 lappend attr "5=$truncationTmpValue"
2722 if {$completenessTmpValue > 0} {
2723 lappend attr "6=$completenessTmpValue"
2725 dputs "new attr $attr"
2726 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2727 destroy .index-setup
2730 proc index-setup {attr queryNo indexNo} {
2733 global relationTmpValue
2734 global structureTmpValue
2735 global truncationTmpValue
2736 global completenessTmpValue
2737 global positionTmpValue
2739 set relationTmpValue 0
2740 set truncationTmpValue 0
2741 set structureTmpValue 0
2742 set positionTmpValue 0
2743 set completenessTmpValue 0
2749 set n [lindex $attr 0]
2750 wm title $w "Index setup $n"
2754 set len [llength $attr]
2755 for {set i 1} {$i < $len} {incr i} {
2756 set q [lindex $attr $i]
2757 set l [string first = $q]
2759 set t [string range $q 0 [expr $l - 1]]
2760 set v [string range $q [expr $l + 1] end]
2763 { set useTmpValue $v }
2765 { set relationTmpValue $v }
2767 { set positionTmpValue $v }
2769 { set structureTmpValue $v }
2771 { set truncationTmpValue $v }
2773 { set completenessTmpValue $v }
2778 frame $w.top.use -relief ridge -border 2
2779 frame $w.top.relation -relief ridge -border 2
2780 frame $w.top.position -relief ridge -border 2
2781 frame $w.top.structure -relief ridge -border 2
2782 frame $w.top.truncation -relief ridge -border 2
2783 frame $w.top.completeness -relief ridge -border 2
2789 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2791 label $w.top.use.label -text "Use"
2793 listbox $w.top.use.list -width 26 \
2794 -yscrollcommand "$w.top.use.scroll set"
2796 listbox $w.top.use.list -geometry 26x10 \
2797 -yscrollcommand "$w.top.use.scroll set"
2799 scrollbar $w.top.use.scroll -orient vertical -border 1
2800 pack $w.top.use.label -side top -fill x \
2802 pack $w.top.use.list -side left -fill both -expand yes \
2804 pack $w.top.use.scroll -side right -fill y \
2806 $w.top.use.scroll config -command "$w.top.use.list yview"
2810 # Relation Attributes
2812 pack $w.top.relation -pady 6 -padx 6 -side top
2813 label $w.top.relation.label -text "Relation" -width 18
2815 pack $w.top.relation.label $w.top.relation.b -fill x
2817 # Position Attributes
2819 pack $w.top.position -pady 6 -padx 6 -side top
2820 label $w.top.position.label -text "Position" -width 18
2822 pack $w.top.position.label $w.top.position.b -fill x
2824 # Structure Attributes
2826 pack $w.top.structure -pady 6 -padx 6 -side top
2827 label $w.top.structure.label -text "Structure" -width 18
2829 pack $w.top.structure.label $w.top.structure.b -fill x
2831 # Truncation Attributes
2833 pack $w.top.truncation -pady 6 -padx 6 -side top
2834 label $w.top.truncation.label -text "Truncation" -width 18
2836 pack $w.top.truncation.label $w.top.truncation.b -fill x
2838 # Completeness Attributes
2840 pack $w.top.completeness -pady 6 -padx 6 -side top
2841 label $w.top.completeness.label -text "Completeness" -width 18
2843 pack $w.top.completeness.label $w.top.completeness.b -fill x
2846 bottom-buttons $w [list \
2847 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2848 {Cancel} [list destroy $w]] 0
2852 proc query-edit-index {queryNo} {
2856 set i [lindex [$w.top.index.list curselection] 0]
2860 set attr [lindex $queryInfoTmp $i]
2861 dputs "Editing no $i $attr"
2862 index-setup $attr $queryNo $i
2865 proc query-delete-index {queryNo} {
2867 global queryButtonsTmp
2870 set i [lindex [$w.top.index.list curselection] 0]
2874 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2875 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2876 $w.top.index.list delete $i
2879 proc query-setup {queryNo} {
2885 global queryButtonsTmp
2887 global queryIndexTmp
2890 set queryName [lindex $queryTypes $queryNo]
2891 set queryInfoTmp [lindex $queryInfo $queryNo]
2892 set queryButtonsTmp [lindex $queryButtons $queryNo]
2897 wm title $w "Query setup $queryName"
2901 frame $w.top.lines -relief ridge -border 2
2903 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2907 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2909 button $w.top.lines.add -text "Add" \
2910 -command [list query-add-line $queryNo]
2911 button $w.top.lines.del -text "Remove" \
2912 -command [list query-del-line $queryNo]
2914 pack $w.top.lines.del -fill x -side bottom
2915 pack $w.top.lines.add -fill x -pady 10 -side bottom
2919 frame $w.top.index -relief ridge -border 2
2920 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2922 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2923 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2924 -command [list $w.top.index.list yview]
2925 bind $w.top.index.list <Double-1> [list query-edit-index $queryNo]
2927 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2928 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2931 $w.top.index.list selection clear 0 end
2932 $w.top.index.list selection set 0 0
2934 $w.top.index.list select from 0
2935 $w.top.index.list select to 0
2938 foreach x $queryInfoTmp {
2939 $w.top.index.list insert end [lindex $x 0]
2943 bottom-buttons $w [list \
2944 Ok [list query-setup-action $queryNo] \
2945 Add [list query-add-index $queryNo] \
2946 Edit [list query-edit-index $queryNo] \
2947 Delete [list query-delete-index $queryNo] \
2948 Cancel [list destroy $w]] 0
2951 proc index-clear {} {
2952 global queryButtonsFind
2955 foreach b $queryButtonsFind {
2956 .lines.$i.e delete 0 end
2961 proc index-query {} {
2962 global queryButtonsFind
2963 global queryInfoFind
2968 foreach b $queryButtonsFind {
2969 set term [string trim [.lines.$i.e get]]
2971 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
2974 set len [string length $term]
2978 if {[string index $term 0] == ">"} {
2979 if {[string index $term 1] == "=" } {
2980 set term [string trim [string range $term 2 $len]]
2983 set term [string trim [string range $term 1 $len]]
2986 } elseif {[string index $term 0] == "<"} {
2987 if {[string index $term 1] == "=" } {
2988 set term [string trim [string range $term 2 $len]]
2990 } elseif {[string index $term 1] == ">"} {
2991 set term [string trim [string range $term 2 $len]]
2994 set term [string trim [string range $term 1 $len]]
2999 set len [string length $term]
3003 if {[string index $term $len] == "?"} {
3005 set term [string range $term 0 [expr $len - 1]]
3007 if {[string index $term 0] == "?"} {
3009 set term [string range $term 1 end]
3011 set term "\{${term}\}"
3012 if {$right && $left} {
3013 set term "@attr 5=3 ${term}"
3015 set term "@attr 5=1 ${term}"
3017 set term "@attr 5=2 ${term}"
3019 if {$relation != ""} {
3020 set term "@attr 2=${relation} ${term}"
3023 set term "@attr $a ${term}"
3026 set qs "@and ${qs} ${term}"
3037 proc index-focus-in {w i} {
3038 global curIndexEntry
3041 $w.$i configure -background red
3043 set curIndexEntry $i
3046 proc index-lines {w realOp buttonInfo queryInfo handle} {
3048 foreach b $buttonInfo {
3049 if {! [winfo exists $w.$i]} {
3051 frame $w.$i -border 0
3053 frame $w.$i -background white -border 1
3056 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
3059 if {! [winfo exists $w.$i.e]} {
3060 entry $w.$i.e -width 32 -relief sunken -border 1
3061 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
3062 bind $w.$i.e <FocusOut> [list $w.$i configure \
3064 pack $w.$i.l -side left
3065 pack $w.$i.e -side left -fill x -expand yes
3066 pack $w.$i -side top -fill x -padx 2 -pady 2
3068 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
3069 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
3071 bind $w.$i.e <Return> {search-request 0}
3074 pack $w.$i.l -side left
3075 pack $w.$i -side top -fill x -padx 2 -pady 2
3080 while {[winfo exists $w.$j]} {
3092 bind $w.$j.e <Tab> "focus $w.$k.e"
3098 bind $w.$i.e <Tab> "focus $w.0.e"
3104 proc search-fields {w buttondefs} {
3106 foreach buttondef $buttondefs {
3107 frame $w.$i -background white
3109 listbutton $w.$i.l 0 $buttondef
3110 entry $w.$i.e -width 32 -relief sunken
3112 pack $w.$i.l -side left
3113 pack $w.$i.e -side left -fill x -expand yes
3115 pack $w.$i -side top -fill x -padx 2 -pady 2
3117 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
3118 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
3126 bind $w.$j.e <Tab> "focus $w.$k.e \n
3127 $w.$k configure -background red \n
3128 $w.$j configure -background white"
3131 bind $w.$i.e <Tab> "focus $w.0.e \n
3132 $w.0 configure -background red \n
3133 $w.$i configure -background white"
3135 $w.0 configure -background red
3138 if {[info exists windowGeometry(.)]} {
3139 set g $windowGeometry(.)
3147 frame .top -border 1 -relief raised
3148 frame .lines -border 1 -relief raised
3149 frame .mid -border 1 -relief raised
3150 frame .data -border 1 -relief raised
3151 frame .bot -border 1 -relief raised
3152 pack .top .lines .mid -side top -fill x
3153 pack .data -side top -fill both -expand yes
3156 menubutton .top.file -text "File" -menu .top.file.m
3158 .top.file.m add command -label "Save settings" -command {save-settings}
3159 .top.file.m add separator
3160 .top.file.m add command -label "Exit" -command {exit-action}
3162 menubutton .top.target -text "Target" -menu .top.target.m
3164 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
3165 .top.target.m add command -label "Disconnect" -command {close-target}
3166 .top.target.m add command -label "About" -command {about-target}
3167 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
3168 .top.target.m add command -label "Setup new" -command {define-target-dialog}
3169 .top.target.m add separator
3170 set-target-hotlist 0
3172 configure-disable-e .top.target.m 1
3173 configure-disable-e .top.target.m 2
3175 menu .top.target.m.clist
3176 menu .top.target.m.slist
3179 menubutton .top.service -text "Service" -menu .top.service.m
3181 .top.service.m add command -label "Database" -command {database-select}
3182 .top.service.m add cascade -label "Present" -menu .top.service.m.present
3183 menu .top.service.m.present
3184 .top.service.m.present add command -label "10 More" \
3185 -command [list present-more 10]
3186 .top.service.m.present add command -label "All" \
3187 -command [list present-more {}]
3188 .top.service.m add command -label "Search" -command {search-request 0}
3189 .top.service.m add command -label "Scan" -command {scan-request}
3191 .top.service configure -state disabled
3193 menubutton .top.rset -text "Set" -menu .top.rset.m
3195 .top.rset.m add command -label "Load" -command {load-set}
3196 .top.rset.m add separator
3198 menubutton .top.options -text "Options" -menu .top.options.m
3200 .top.options.m add cascade -label "Query" -menu .top.options.m.query
3201 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
3202 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
3203 .top.options.m add cascade -label "Syntax" -menu .top.options.m.syntax
3204 .top.options.m add cascade -label "Elements" -menu .top.options.m.elements
3206 menu .top.options.m.query
3207 .top.options.m.query add cascade -label "Select" \
3208 -menu .top.options.m.query.clist
3209 .top.options.m.query add cascade -label "Edit" \
3210 -menu .top.options.m.query.slist
3211 .top.options.m.query add command -label "New" \
3212 -command {query-new}
3213 .top.options.m.query add cascade -label "Delete" \
3214 -menu .top.options.m.query.dlist
3216 menu .top.options.m.query.slist
3217 menu .top.options.m.query.clist
3218 menu .top.options.m.query.dlist
3221 menu .top.options.m.formats
3223 foreach f $displayFormats {
3224 .top.options.m.formats add radiobutton -label $f -value $i \
3225 -command [list set-display-format $i] -variable displayFormat
3229 menu .top.options.m.wrap
3230 .top.options.m.wrap add radiobutton -label "Character" \
3231 -value char -variable textWrap -command {set-wrap char}
3232 .top.options.m.wrap add radiobutton -label "Word" \
3233 -value word -variable textWrap -command {set-wrap word}
3234 .top.options.m.wrap add radiobutton -label "None" \
3235 -value none -variable textWrap -command {set-wrap none}
3237 menu .top.options.m.syntax
3238 .top.options.m.syntax add radiobutton -label "None" \
3239 -value None -variable recordSyntax
3240 .top.options.m.syntax add separator
3241 .top.options.m.syntax add radiobutton -label "USMARC" \
3242 -value USMARC -variable recordSyntax
3243 .top.options.m.syntax add radiobutton -label "UNIMARC" \
3244 -value UNIMARC -variable recordSyntax
3245 .top.options.m.syntax add radiobutton -label "UKMARC" \
3246 -value UKMARC -variable recordSyntax
3247 .top.options.m.syntax add radiobutton -label "DANMARC" \
3248 -value DANMARC -variable recordSyntax
3249 .top.options.m.syntax add radiobutton -label "FINMARC" \
3250 -value FINMARC -variable recordSyntax
3251 .top.options.m.syntax add radiobutton -label "NORMARC" \
3252 -value NORMARC -variable recordSyntax
3253 .top.options.m.syntax add radiobutton -label "PICAMARC" \
3254 -value PICAMARC -variable recordSyntax
3255 .top.options.m.syntax add separator
3256 .top.options.m.syntax add radiobutton -label "SUTRS" \
3257 -value SUTRS -variable recordSyntax
3258 .top.options.m.syntax add separator
3259 .top.options.m.syntax add radiobutton -label "GRS1" \
3260 -value GRS1 -variable recordSyntax
3262 menu .top.options.m.elements
3263 .top.options.m.elements add radiobutton -label "Unspecified" \
3264 -value None -variable elementSetNames
3265 .top.options.m.elements add radiobutton -label "Full" \
3266 -value F -variable elementSetNames
3267 .top.options.m.elements add radiobutton -label "Brief" \
3268 -value B -variable elementSetNames
3270 menubutton .top.help -text "Help" -menu .top.help.m
3273 .top.help.m add command -label "Help on help" \
3274 -command {tkerror "Help on help not available. Sorry"}
3275 .top.help.m add command -label "About" -command {about-origin}
3277 pack .top.file .top.target .top.service .top.rset .top.options -side left
3278 pack .top.help -side right
3280 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
3282 button .mid.search -text Search -command {search-request 0} \
3284 button .mid.scan -text Scan \
3285 -command scan-request -state disabled
3286 button .mid.present -text {Present} -command [list present-more 10] \
3289 button .mid.clear -text Clear -command index-clear
3290 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
3293 text .data.record -height 2 -width 20 -wrap none \
3294 -yscrollcommand [list .data.scroll set] -wrap $textWrap
3295 scrollbar .data.scroll -command [list .data.record yview]
3297 .data.record configure -takefocus 0
3298 .data.scroll configure -takefocus 0
3300 pack .data.scroll -side right -fill y
3301 pack .data.record -expand yes -fill both
3305 .data.record tag configure marc-tag -foreground blue
3306 .data.record tag configure marc-id -foreground red
3308 .data.record tag configure marc-tag -foreground black
3309 .data.record tag configure marc-id -foreground black
3311 .data.record tag configure marc-data -foreground black
3312 .data.record tag configure marc-head \
3313 -font -Adobe-Times-Bold-R-Normal-*-140-* \
3314 -foreground brown -relief raised -borderwidth 1
3315 .data.record tag configure marc-small-head -foreground brown
3316 .data.record tag configure marc-pref \
3317 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3319 .data.record tag configure marc-text \
3320 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3322 .data.record tag configure marc-it \
3323 -font -Adobe-Times-Medium-I-Normal-*-140-* \
3326 button .bot.logo -bitmap @${libdir}/bitmaps/book1 -command cancel-operation
3328 .bot.logo configure -takefocus 0
3331 pack .bot.a -side left -fill x
3332 pack .bot.logo -side right -padx 2 -pady 2 -ipadx 1
3334 message .bot.a.target -text "" -aspect 1000 -border 1
3336 label .bot.a.status -text "Not connected" -width 15 -relief \
3337 sunken -anchor w -border 1
3338 label .bot.a.set -text "" -width 5 -relief \
3339 sunken -anchor w -border 1
3340 label .bot.a.message -text "" -width 15 -relief \
3341 sunken -anchor w -border 1
3343 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
3344 pack .bot.a.status .bot.a.set .bot.a.message \
3345 -side left -padx 2 -pady 2 -ipadx 1 -ipady 1
3347 if {[catch {ir z39}]} {
3348 set e [info sharedlibextension]
3349 puts -nonewline "Loading irtcl$e ..."
3356 if {$hostid != "Default"} {
3357 catch {open-target $hostid $hostbase}