1 # IR toolkit for tcl/tk
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
7 # Revision 1.84 1996-01-11 13:12:10 adam
10 # Revision 1.83 1995/11/28 17:26:36 adam
11 # Removed Carriage return from ir-tcl.c!
12 # Removed misc. debug logs.
14 # Revision 1.82 1995/11/02 08:47:56 adam
15 # Text widgets are flat now.
17 # Revision 1.81 1995/10/19 10:34:43 adam
18 # More configurable client.
20 # Revision 1.80 1995/10/18 17:20:32 adam
21 # Work on target setup in client.tcl.
23 # Revision 1.79 1995/10/18 16:42:37 adam
24 # New settings: smallSetElementSetNames and mediumSetElementSetNames.
26 # Revision 1.78 1995/10/18 15:45:36 quinn
27 # *** empty log message ***
29 # Revision 1.77 1995/10/18 15:37:46 adam
32 # Revision 1.76 1995/10/18 15:15:20 adam
35 # Revision 1.75 1995/10/17 14:18:05 adam
36 # Minor changes in presentation formats.
38 # Revision 1.74 1995/10/17 12:18:57 adam
39 # Bug fix: when target connection closed, the connection was not
40 # properly reestablished.
42 # Revision 1.73 1995/10/17 10:58:06 adam
43 # More work on presentation formats.
45 # Revision 1.72 1995/10/16 17:00:52 adam
46 # New setting: elementSetNames.
47 # Various client improvements. Medium presentation format looks better.
49 # Revision 1.71 1995/10/13 15:35:27 adam
50 # Relational operators may be used in search entries - changes
51 # in proc index-query.
53 # Revision 1.70 1995/10/12 14:46:52 adam
54 # Better record popup windows. Next/prev buttons in popup record windows.
55 # The record position in the raw format is much more visible.
57 # Revision 1.69 1995/09/21 13:42:54 adam
60 # Revision 1.68 1995/09/21 13:11:49 adam
61 # Support of dynamic loading.
62 # Test script uses load command if necessary.
64 # Revision 1.67 1995/09/20 14:35:19 adam
67 # Revision 1.66 1995/08/29 15:30:13 adam
68 # Work on GRS records.
70 # Revision 1.65 1995/08/24 15:39:09 adam
73 # Revision 1.64 1995/08/24 15:33:02 adam
76 # Revision 1.63 1995/08/04 13:20:48 adam
77 # Buttons at the bottom are slightly smaller.
79 # Revision 1.62 1995/08/04 11:32:37 adam
80 # More work on output queue. Memory related routines moved
83 # Revision 1.61 1995/07/20 08:09:39 adam
84 # client.tcl: Targets removed from hotTargets list when targets
85 # are removed/modified.
86 # ir-tcl.c: More work on triggerResourceControl.
88 # Revision 1.60 1995/06/30 16:30:19 adam
91 # Revision 1.59 1995/06/29 14:06:25 adam
92 # Another bug in install fixed. Configure searches for more versions of yaz.
94 # Revision 1.58 1995/06/29 12:34:06 adam
95 # IrTcl now works with both tk4.0b4/tcl7.4b4 and tk3.6/tcl7.3
97 # Revision 1.57 1995/06/29 09:20:30 adam
98 # Target entries in cascade menus are sorted.
100 # Revision 1.56 1995/06/27 19:03:48 adam
101 # Bug fix in do_present in ir-tcl.c: p->set_child member weren't set.
102 # nextResultSetPosition used instead of setOffset.
104 # Revision 1.55 1995/06/27 17:10:37 adam
105 # Bug fix: install procedure didn't work on some systems.
106 # Error turned up when clientrc.tcl was't present.
108 # Revision 1.54 1995/06/27 14:41:03 adam
109 # Bug fix in search-response. Didn't always observe non-surrogate diagnostics.
111 # Revision 1.53 1995/06/26 12:40:09 adam
112 # Client defines its own tkerror.
113 # User may specify 'no preferredRecordSyntax'.
115 # Revision 1.52 1995/06/22 13:14:59 adam
116 # Feature: SUTRS. Setting getSutrs implemented.
117 # Work on display formats.
118 # Preferred record syntax can be set by the user.
120 # Revision 1.51 1995/06/21 11:11:00 adam
121 # Bug fix: libdir undefined in about-origin.
123 # Revision 1.50 1995/06/21 11:04:48 adam
124 # Uses GNU autoconf 2.3.
125 # Install procedure implemented.
126 # boook bitmaps moved to sub directory bitmaps.
128 # Revision 1.49 1995/06/20 14:16:42 adam
129 # More work on cancel mechanism.
131 # Revision 1.48 1995/06/20 08:07:23 adam
132 # New setting: failInfo.
133 # Working on better cancel mechanism.
135 # Revision 1.47 1995/06/19 14:05:29 adam
136 # Bug fix: asked for SUTRS.
138 # Revision 1.46 1995/06/19 13:06:06 adam
139 # New define: IR_TCL_VERSION.
141 # Revision 1.45 1995/06/19 08:08:44 adam
142 # client.tcl: hotTargets now contain both database and target name.
143 # ir-tcl.c: setting protocol edited. Errors in callbacks are logged
144 # by logf(LOG_WARN, ...) calls.
146 # Revision 1.44 1995/06/16 14:55:18 adam
147 # Book logo mirrored.
149 # Revision 1.43 1995/06/16 14:41:05 adam
150 # Scan line entries can be copied to a search entry.
152 # Revision 1.42 1995/06/16 12:28:13 adam
153 # Implemented preferredRecordSyntax.
154 # Minor changes in diagnostic handling.
155 # Record list deleted when connection closes.
157 # Revision 1.41 1995/06/14 15:07:59 adam
158 # Bug fix in cascade-target-list. Uses yaz-version.h.
160 # Revision 1.40 1995/06/14 13:37:17 adam
161 # Setting recordType implemented.
162 # Setting implementationVersion implemented.
163 # Settings implementationId / implementationName edited.
165 # Revision 1.39 1995/06/14 12:16:22 adam
166 # hotTargets, textWrap and displayFormat saved in clientg.tcl.
168 # Revision 1.38 1995/06/14 07:22:45 adam
169 # Target definitions can be deleted.
170 # Listbox used in the query definition dialog.
172 # Revision 1.37 1995/06/13 14:37:59 adam
173 # Work on query setup.
174 # Better about origin/target.
175 # Better presentation formats.
177 # Revision 1.36 1995/06/13 07:42:14 adam
178 # Bindings removed from text widgets.
180 # Revision 1.35 1995/06/12 15:17:31 adam
181 # Text widget used in main window (instead of listbox) to support
182 # better presentation formats.
184 # Revision 1.34 1995/06/12 07:59:07 adam
185 # More work on geometry handling.
187 # Revision 1.33 1995/06/09 11:17:35 adam
188 # Start work on geometry management.
190 # Revision 1.32 1995/06/07 09:16:37 adam
191 # New presentation format.
193 # Revision 1.31 1995/06/06 16:31:09 adam
194 # Bug fix: target names couldn't contain blanks.
197 # Revision 1.30 1995/06/06 11:35:41 adam
198 # Work on scan. Display of old sets.
200 # Revision 1.29 1995/06/05 14:11:18 adam
201 # Bug fix in present-more.
203 # Revision 1.28 1995/06/02 14:52:13 adam
204 # Minor changes really.
206 # Revision 1.27 1995/06/02 14:29:42 adam
207 # Work on scan interface - up/down buttons.
209 # Revision 1.26 1995/06/01 16:36:46 adam
210 # About buttons. Minor bug fixes.
212 # Revision 1.25 1995/05/31 13:09:57 adam
213 # Client searches/presents may be interrupted.
214 # New moving book-logo.
216 # Revision 1.24 1995/05/31 08:36:24 adam
217 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
218 # New method: referenceId. More work on scan.
220 # Revision 1.23 1995/05/29 10:33:41 adam
221 # README and rename of startup script.
223 # Revision 1.22 1995/05/26 11:44:09 adam
224 # Bugs fixed. More work on MARC utilities and queries. Test
225 # client is up-to-date again.
227 # Revision 1.21 1995/05/11 15:34:46 adam
228 # Scan request changed a bit. This version works with RLG.
230 # Revision 1.20 1995/04/21 16:31:57 adam
231 # New radiobutton: protocol (z39v2/SR).
233 # Revision 1.19 1995/04/18 16:11:50 adam
234 # First version of graphical Scan. Some work on query-by-form.
236 # Revision 1.18 1995/04/10 10:50:22 adam
237 # Result-set name defaults to suffix of ir-set name.
238 # Started working on scan. Not finished at this point.
240 # Revision 1.17 1995/03/31 09:34:57 adam
241 # Search-button disabled when there is no connection.
243 # Revision 1.16 1995/03/31 08:56:36 adam
244 # New button "Search".
246 # Revision 1.15 1995/03/28 12:45:22 adam
247 # New ir method failback: called on disconnect/protocol error.
248 # New ir set/get method: protocol: SR / Z3950.
249 # Simple popup and disconnect when failback is invoked.
251 # Revision 1.14 1995/03/22 16:07:55 adam
254 # Revision 1.13 1995/03/21 17:27:26 adam
255 # Short-hand keys in setup.
257 # Revision 1.12 1995/03/21 13:41:03 adam
258 # Comstack cs_create not used too often. Non-blocking connect.
260 # Revision 1.11 1995/03/21 10:39:06 adam
261 # Diagnostic error message displayed with tkerror.
263 # Revision 1.10 1995/03/20 15:24:06 adam
264 # Diagnostic records saved on searchResponse.
266 # Revision 1.9 1995/03/17 18:26:16 adam
267 # Non-blocking i/o used now. Database names popup as cascade items.
269 # Revision 1.8 1995/03/17 15:45:00 adam
270 # Improved target/database setup.
272 # Revision 1.7 1995/03/16 17:54:03 adam
273 # Minor changes really.
275 # Revision 1.6 1995/03/15 19:10:20 adam
276 # Database setup in protocol-setup (rather target setup).
278 # Revision 1.5 1995/03/15 13:59:23 adam
281 # Revision 1.4 1995/03/14 17:32:29 adam
282 # Presentation of full Marc record in popup window.
284 # Revision 1.3 1995/03/12 19:31:52 adam
285 # Pattern matching implemented when retrieving MARC records. More
286 # diagnostic functions.
288 # Revision 1.2 1995/03/10 18:00:15 adam
289 # Actual presentation in line-by-line format. RPN query support.
291 # Revision 1.1 1995/03/09 16:15:07 adam
292 # First presentRequest attempts. Hot-target list.
296 if {$tk_version == "3.6"} {
307 proc configure-enable-e {w n} {
309 $w entryconfigure $n -state normal
311 proc configure-disable-e {w n} {
313 $w entryconfigure $n -state disabled
315 set noFocus [list -takefocus 0]
317 proc configure-enable-e {w n} {
320 proc configure-disable-e {w n} {
327 if {[tk colormodel .] == "color"} {
337 if {[file readable bitmaps/book2]} {
340 if {! [file readable ${libdir}/bitmaps/book2]} {
341 puts "Cannot locate system files in ${libdir}. You must either run this"
342 puts "program from the source directory root of ir-tcl or you must assure"
343 puts "that it is installed - normally in /usr/local/lib/irtcl"
351 set profile(Default) {{} {} {210} {} 50000 30000 tcpip {} 1 {} {} Z39 1 2 0 0 4}
353 set settingsChanged 0
361 set recordSyntax None
362 set elementSetNames None
365 set queryTypes {Simple}
366 set queryButtons { { {I 0} {I 1} {I 2} } }
367 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
368 {Subject {1=21}} {Any {1=1016}} } }
377 if {[winfo exists $w]} {
386 label $w.top.b -bitmap error
387 message $w.top.t -aspect 300 -text "Error: $err" \
388 -font -Adobe-Helvetica-Bold-R-Normal-*-180-*
389 pack $w.top.b $w.top.t -side left -padx 10 -pady 10
391 bottom-buttons $w [list {Close} [list destroy $w]] 1
394 if {[file readable "clientrc.tcl"]} {
395 source "clientrc.tcl"
397 if {[file readable "${libdir}/clientrc.tcl"]} {
398 source "${libdir}/clientrc.tcl"
402 if {[file readable "~/.clientrc.tcl"]} {
403 source "~/.clientrc.tcl"
406 set queryButtonsFind [lindex $queryButtons 0]
407 set queryInfoFind [lindex $queryInfo 0]
409 proc read-formats {} {
410 global displayFormats
412 if {[catch {set formats [glob -nocomplain ${libdir}/formats/*.tcl]}]} {
413 set formats ./formats/raw.tcl
416 if {[file readable $f]} {
418 set l [string length $f]
419 set f [string range $f [string length "${libdir}/formats/"] \
421 lappend displayFormats $f
430 .data.record configure -wrap $m
437 proc set-display-format {f} {
447 .bot.a.status configure -text "Reformatting"
450 add-title-lines -1 10000 1
453 proc initBindings {} {
456 bind $w <Double-1> {}
457 bind $w <Triple-1> {}
458 bind $w <B1-Motion> {}
460 bind $w <Shift-B1-Motion> {}
462 bind $w <B2-Motion> {}
463 bind $w <Any-KeyPress> {}
465 bind $w <BackSpace> {}
467 bind $w <Control-h> {}
468 bind $w <Control-d> {}
469 bind $w <Control-v> {}
472 bind $w <B1-Motion> {}
473 bind $w <Shift-B1-Motion> {}
478 proc post-menu {wbutton wmenu} {
481 $wmenu post [winfo rootx $wbutton] \
482 [expr [winfo rooty $wbutton]+[winfo height $wbutton]]
487 global windowGeometry
488 set windowGeometry($w) [wm geometry $w]
491 global windowGeometry
494 if {[info exists windowGeometry($w)]} {
495 set g $windowGeometry($w)
500 bind $w <Destroy> [list destroyGW $w]
504 proc top-down-window {w} {
505 frame $w.top -relief raised -border 1
506 frame $w.bot -relief raised -border 1
508 pack $w.top -side top -fill both -expand yes
509 pack $w.bot -fill both
512 proc top-down-ok-cancel {w ok-action g} {
513 frame $w.bot.left -relief sunken -border 1
514 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 1 -pady 1
515 button $w.bot.left.ok -width 4 -text {Ok} \
516 -command ${ok-action}
517 pack $w.bot.left.ok -expand yes -ipadx 1 -ipady 1 -padx 2 -pady 2
518 button $w.bot.cancel -width 5 -text {Cancel} \
519 -command [list destroy $w]
520 pack $w.bot.cancel -side left -expand yes
528 proc bottom-buttons {w buttonList g} {
530 set l [llength $buttonList]
532 frame $w.bot.$i -relief sunken -border 1
533 pack $w.bot.$i -side left -expand yes -padx 2 -pady 2
534 button $w.bot.$i.ok -text [lindex $buttonList $i] \
535 -command [lindex $buttonList [expr $i+1]]
536 pack $w.bot.$i.ok -expand yes -padx 2 -pady 2 -side left
540 button $w.bot.$i -text [lindex $buttonList $i] \
541 -command [lindex $buttonList [expr $i+1]]
542 pack $w.bot.$i -expand yes -padx 2 -pady 2 -side left
552 proc cancel-operation {} {
560 show-status Cancel 0 1
564 proc show-target {target base} {
568 .bot.a.target configure -text ""
572 .bot.a.target configure -text "$target"
574 .bot.a.target configure -text "$target - $base"
578 proc show-logo {v1} {
587 .bot.logo configure -bitmap @${libdir}/bitmaps/book${v1}
588 after 140 [list show-logo $v1]
592 .bot.logo configure -bitmap @${libdir}/bitmaps/book1
601 proc show-status {status b sb} {
608 .bot.a.status configure -text "$status"
610 if {$busy == 0} {set busy 1}
618 .top.service configure -state normal
619 .mid.search configure -state normal
621 .mid.scan configure -state normal
624 configure-disable-e .top.service.m 1
625 } elseif {[z39.$setNo nextResultSetPosition] > 0 &&
626 [z39.$setNo nextResultSetPosition] <= [z39.$setNo resultCount]} {
627 configure-enable-e .top.service.m 1
628 .mid.present configure -state normal
630 configure-disable-e .top.service.m 1
631 .mid.present configure -state disabled
633 if {[winfo exists .scan-window]} {
634 .scan-window.bot.2 configure -state normal
635 .scan-window.bot.4 configure -state normal
638 .top.service configure -state disabled
639 .mid.search configure -state disabled
640 .mid.scan configure -state disabled
641 .mid.present configure -state disabled
643 if {[winfo exists .scan-window]} {
644 .scan-window.bot.2 configure -state disabled
645 .scan-window.bot.4 configure -state disabled
650 proc show-message {msg} {
651 .bot.a.message configure -text "$msg"
654 proc insertWithTags {w text args} {
655 set start [$w index insert]
656 $w insert insert $text
657 foreach tag [$w tag names $start] {
658 $w tag remove $tag $start insert
661 $w tag add $i $start insert
665 proc popup-license {} {
670 wm title $w "License"
676 text $w.top.t -width 80 -height 10 -wrap word -relief flat -borderwidth 0 \
677 -yscrollcommand [list $w.top.s set]
678 scrollbar $w.top.s -command [list $w.top.t yview]
680 pack $w.top.s -side right -fill y
681 pack $w.top.t -expand yes -fill both
683 if {[file readable "${libdir}/LICENSE"]} {
684 set f [open "${libdir}/LICENSE" r]
685 while {[gets $f buf] != -1} {
686 $w.top.t insert end $buf
687 $w.top.t insert end "\n"
691 bottom-buttons $w [list {Close} [list destroy $w]] 1
694 proc about-target {} {
695 set w .about-target-w
700 wm title $w "About target"
704 frame $w.top.a -relief ridge -border 2
705 frame $w.top.p -relief ridge -border 2
707 pack $w.top.a $w.top.p -side top -fill x
709 label $w.top.a.about -text "About"
710 label $w.top.a.irtcl -text $hostid \
711 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
712 pack $w.top.a.about $w.top.a.irtcl -side top
714 set i [z39 targetImplementationName]
715 label $w.top.p.in -text "Implementation name: $i"
716 set i [z39 targetImplementationId]
717 label $w.top.p.ii -text "Implementation id: $i"
718 set i [z39 targetImplementationVersion]
719 label $w.top.p.iv -text "Implementation version: $i"
721 label $w.top.p.op -text "Protocol options: $i"
723 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
725 bottom-buttons $w [list {Close} [list destroy $w]] 1
728 proc about-origin-logo {n} {
730 set w .about-origin-w
731 if {![winfo exists $w]} {
738 $w.top.a.logo configure -bitmap @${libdir}/bitmaps/book$n
739 after 140 [list about-origin-logo $n]
742 proc about-origin {} {
743 set w .about-origin-w
747 if {[winfo exists $w]} {
752 wm title $w "About IrTcl"
756 frame $w.top.a -relief ridge -border 2
757 frame $w.top.p -relief ridge -border 2
759 pack $w.top.a $w.top.p -side top -fill x
761 label $w.top.a.irtcl -text "IrTcl" \
762 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
763 label $w.top.a.logo -bitmap @${libdir}/bitmaps/book1
764 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
767 catch {set i [z39 implementationName]}
768 label $w.top.p.in -text "Implementation name: $i"
769 catch {set i [z39 implementationId]}
770 label $w.top.p.ii -text "Implementation id: $i"
771 catch {set i [z39 implementationVersion]}
772 label $w.top.p.iv -text "Implementation version: $i"
774 label $w.top.p.tk -text "Tk version: $i"
776 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.tk -side top -anchor nw
779 bottom-buttons $w [list {Close} [list destroy $w] \
780 {License} [list popup-license]] 0
783 proc popup-marc {sno no b df} {
784 global displayFormats
787 if {[z39.$sno type $no] != "DB"} {
792 while {[winfo exists .full-marc$b]} {
798 if {![winfo exists $w]} {
803 frame $w.top -relief raised -border 1
804 frame $w.bot -relief raised -border 1
806 pack $w.top -side top -fill both -expand yes
807 pack $w.bot -fill both
809 text $w.top.record -width 60 -height 5 -wrap word -relief flat -borderwidth 0 \
810 -yscrollcommand [list $w.top.s set]
811 scrollbar $w.top.s -command [list $w.top.record yview]
815 $w.top.record tag configure marc-tag -foreground blue
816 $w.top.record tag configure marc-id -foreground red
818 $w.top.record tag configure marc-tag -foreground black
819 $w.top.record tag configure marc-id -foreground black
821 $w.top.record tag configure marc-data -foreground black
822 $w.top.record tag configure marc-head \
823 -font -Adobe-Times-Medium-R-Normal-*-180-* \
824 -background black -foreground white
826 $w.top.record tag configure marc-pref \
827 -font -Adobe-Times-Medium-R-Normal-*-180-* \
829 $w.top.record tag configure marc-text \
830 -font -Adobe-Times-Medium-R-Normal-*-180-* \
832 $w.top.record tag configure marc-it \
833 -font -Adobe-Times-Medium-I-Normal-*-180-* \
836 pack $w.top.s -side right -fill y
837 pack $w.top.record -expand yes -fill both
839 bottom-buttons $w [list \
840 {Close} [list destroy $w] \
844 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m \
846 menu $w.bot.formats.m
847 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 \
848 -padx 3 -pady 3 -side left
850 $w.bot.formats.m delete 0 last
853 foreach f $displayFormats {
854 $w.bot.formats.m add radiobutton -label $f \
855 -variable popupMarcdf -value $i \
856 -command [list popup-marc $sno $no $b 0]
859 $w.top.record delete 0.0 end
860 set recordType [z39.$sno recordType $no]
861 wm title $w "$recordType record #$no"
863 $w.bot.2 configure -command \
864 [list popup-marc $sno [expr $no-1] $b $df]
865 $w.bot.4 configure -command \
866 [list popup-marc $sno [expr $no+1] $b $df]
868 $w.bot.2 configure -state disabled
870 $w.bot.2 configure -state normal
872 if {[z39.$sno type [expr $no+1]] != "DB"} {
873 $w.bot.4 configure -state disabled
875 $w.bot.4 configure -state normal
877 $w.bot.6 configure -command [list popup-marc $sno $no -1 0]
878 set ffunc [lindex $displayFormats $df]
879 set ffunc "display-$ffunc"
881 $ffunc $sno $no $w.top.record 0
884 proc update-target-hotlist {target base} {
887 set olen [llength $hotTargets]
889 foreach e $hotTargets {
890 if {$target == [lindex $e 0] && $base == [lindex $e 1]} {
891 set hotTargets [lreplace $hotTargets $i $i]
896 set hotTargets [linsert $hotTargets 0 [list $target $base]]
897 set-target-hotlist $olen
900 proc delete-target-hotlist {target} {
903 set olen [llength $hotTargets]
905 foreach e $hotTargets {
906 if {$target == [lindex $e 0]} {
907 set hotTargets [lreplace $hotTargets $i $i]
911 set-target-hotlist $olen
914 proc set-target-hotlist {olen} {
919 .top.target.m delete 7 [expr 7+$olen]
921 .top.target.m delete 6 [expr 6+$olen]
925 foreach e $hotTargets {
926 set target [lindex $e 0]
927 set base [lindex $e 1]
929 .top.target.m add command -label "$i $target" -command \
930 [list reopen-target $target {}]
932 .top.target.m add command -label "$i $target - $base" -command \
933 [list reopen-target $target $base]
942 proc reopen-target {target base} {
944 open-target $target $base
945 update-target-hotlist $target $base
948 proc define-target-action {} {
951 set target [.target-define.top.target.entry get]
955 foreach n [array names profile] {
957 destroy .target-define
962 set seq [lindex $profile(Default) 12]
964 dputs $profile(Default)
965 set profile($target) $profile(Default)
966 set profile(Default) [lreplace $profile(Default) 12 12 [incr seq]]
968 protocol-setup $target
969 destroy .target-define
972 proc fail-response {target} {
973 set c [lindex [z39 failInfo] 0]
974 set m [lindex [z39 failInfo] 1]
979 proc connect-response {target base} {
980 dputs "connect-response"
981 show-target $target $base
985 proc open-target {target base} {
991 z39 comstack [lindex $profile($target) 6]
992 z39 protocol [lindex $profile($target) 11]
993 z39 idAuthentication [lindex $profile($target) 3]
994 z39 maximumRecordSize [lindex $profile($target) 4]
995 z39 preferredMessageSize [lindex $profile($target) 5]
996 dputs "maximumRecordSize="
997 dputs [z39 maximumRecordSize]
998 dputs "preferredMessageSize="
999 dputs [z39 preferredMessageSize]
1000 show-status Connecting 1 0
1002 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
1004 z39 databaseNames $base
1006 set x [lindex $profile($target) 13]
1010 z39 largeSetLowerBound $x
1012 set x [lindex $profile($target) 14]
1016 z39 smallSetUpperBound $x
1018 set x [lindex $profile($target) 15]
1022 z39 mediumSetPresentNumber $x
1024 set presentChunk [lindex $profile($target) 16]
1025 if {$presentChunk == ""} {
1029 z39 failback [list fail-response $target]
1030 z39 callback [list connect-response $target $base]
1033 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
1036 tkerror $errorMessage
1037 show-status "Not connected" 0 {}
1041 configure-disable-e .top.target.m 0
1042 configure-enable-e .top.target.m 1
1043 configure-enable-e .top.target.m 2
1046 proc close-target {} {
1055 .bot.a.set configure -text ""
1059 show-status {Not connected} 0 0
1062 configure-disable-e .top.target.m 1
1063 configure-disable-e .top.target.m 2
1065 .top.rset.m delete 2 last
1067 .top.rset.m delete 1 last
1069 .top.rset.m add separator
1070 configure-enable-e .top.target.m 0
1073 proc load-set-action {} {
1077 ir-set z39.$setNoLast z39
1079 set fname [.load-set.top.filename.entry get]
1082 show-status Loading 1 {}
1084 z39.$setNoLast loadFile $fname
1086 set no [z39.$setNoLast numberOfRecordsReturned]
1087 add-title-lines $setNoLast $no 1
1089 set l [format "%-4d %7d" $setNoLast $no]
1090 .top.rset.m add command -label $l \
1091 -command [list add-title-lines $setNoLast 10000 1]
1092 show-status Ready 0 {}
1098 set oldFocus [focus]
1102 frame $w.top.filename
1103 pack $w.top.filename -side top -anchor e -pady 2
1105 entry-fields $w.top {filename} \
1107 {load-set-action} {destroy .load-set}
1109 top-down-ok-cancel $w {load-set-action} 1
1113 proc init-request {} {
1120 z39 callback {init-response}
1121 show-status Initializing 1 {}
1122 set err [catch {z39 init} errorMessage]
1124 tkerror $errorMessage
1125 show-status Ready 0 {}
1129 proc init-response {} {
1133 dputs {init-reponse}
1138 if {![z39 initResult]} {
1139 show-status Ready 0 1
1140 set u [z39 userInformationField]
1142 tkerror "Connection rejected by target: $u"
1144 if {[lsearch [z39 options] scan] >= 0} {
1149 show-status Ready 0 1
1153 proc search-request {bflag} {
1162 global elementSetNames
1166 if {[z39 connect] == ""} {
1169 dputs "search-request"
1171 if {!$bflag && $busy} {
1172 dputs "busy: search-request ignored"
1177 show-status Searching 1 0
1178 set delayRequest {search-request 1}
1183 set query [index-query]
1188 set setNo $setNoLast
1189 ir-set z39.$setNo z39
1191 if {[lindex $profile($target) 10] == 1} {
1192 z39.$setNo setName $setNo
1193 dputs "setName=${setNo}"
1195 z39.$setNo setName Default
1196 dputs "setName=Default"
1198 if {[lindex $profile($target) 8] == 1} {
1199 z39.$setNo queryType rpn
1201 if {[lindex $profile($target) 9] == 1} {
1202 z39.$setNo queryType ccl
1206 if {$recordSyntax == "None" } {
1207 z39.$setNo preferredRecordSyntax {}
1209 z39.$setNo preferredRecordSyntax $recordSyntax
1211 if {$elementSetNames == "None" } {
1212 z39.$setNo elementSetNames {}
1213 z39.$setNo smallSetElementSetNames {}
1214 z39.$setNo mediumSetElementSetNames {}
1216 z39.$setNo elementSetNames $elementSetNames
1217 z39.$setNo smallSetElementSetNames $elementSetNames
1218 z39.$setNo mediumSetElementSetNames $elementSetNames
1220 z39 callback {search-response}
1221 z39.$setNo search $query
1222 show-status Searching 1 0
1225 proc scan-copy {y entry} {
1227 set no [$w.top.list nearest $y]
1229 .lines.$entry.e delete 0 end
1230 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
1233 proc scan-request {} {
1240 global curIndexEntry
1241 global queryButtonsFind
1242 global queryInfoFind
1246 dputs "scan-request"
1249 show-status Scanning 1 0
1250 set delayRequest scan-request
1259 set b [lindex $queryButtonsFind $curIndexEntry]
1261 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
1262 set attr "@attr $a $attr"
1264 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
1265 ir-scan z39.scan z39
1267 if {![winfo exists $w]} {
1274 entry $w.top.entry -relief sunken
1275 pack $w.top.entry -fill x -padx 4 -pady 2
1276 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
1277 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
1279 scrollbar $w.top.scroll -orient vertical -border 1
1280 pack $w.top.list -side left -fill both -expand yes
1281 pack $w.top.scroll -side right -fill y
1282 $w.top.scroll config -command [list $w.top.list yview]
1284 bottom-buttons $w [list {Close} [list destroy $w] \
1285 {Up} [list scan-up $attr] \
1286 {Down} [list scan-down $attr]] 0
1287 bind $w.top.list <Up> [list scan-up $attr]
1288 bind $w.top.list <Down> [list scan-down $attr]
1291 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
1292 wm title $w "Scan $title"
1294 z39 callback [list scan-response $attr 0 35]
1295 z39.scan numberOfTermsRequested 5
1296 z39.scan preferredPositionInResponse 1
1297 z39.scan scan "${attr} 0"
1299 show-status Scanning 1 0
1302 proc scan-term-h {attr} {
1310 set nScanTerm [$w.top.entry get]
1311 if {$nScanTerm == $scanTerm} {
1314 set scanTerm $nScanTerm
1315 z39 callback [list scan-response $attr 0 35]
1316 z39.scan numberOfTermsRequested 5
1317 z39.scan preferredPositionInResponse 1
1318 dputs "${attr} \{${scanTerm}\}"
1319 if {$scanTerm == ""} {
1320 z39.scan scan "${attr} 0"
1322 z39.scan scan "${attr} \{${scanTerm}\}"
1324 show-status Scanning 1 0
1327 proc scan-response {attr start toget} {
1334 dputs "In scan-response"
1335 set m [z39.scan numberOfEntriesReturned]
1341 if {![winfo exists .scan-window]} {
1344 dputs "Handling cancel"
1345 if {$delayRequest != ""} {
1350 show-status Ready 0 1
1353 set nScanTerm [$w.top.entry get]
1354 if {$nScanTerm != $scanTerm} {
1355 z39 callback [list scan-response $attr 0 35]
1356 z39.scan numberOfTermsRequested 5
1357 z39.scan preferredPositionInResponse 1
1358 set scanTerm $nScanTerm
1359 dputs "${attr} \{${scanTerm}\}"
1360 if {$scanTerm == ""} {
1361 z39.scan scan "${attr} 0"
1363 z39.scan scan "${attr} \{${scanTerm}\}"
1365 show-status Scanning 1 0
1368 set status [z39.scan scanStatus]
1371 show-status Ready 0 1
1376 for {set i 0} {$i < $m} {incr i} {
1377 set term [lindex [z39.scan scanLine $i] 1]
1378 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1379 $w.top.list insert $i "$nostr $term"
1382 $w.top.list yview $scanView
1384 $w.top.list delete $start end
1385 for {set i 0} {$i < $m} {incr i} {
1386 set term [lindex [z39.scan scanLine $i] 1]
1387 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1388 $w.top.list insert end "$nostr $term"
1392 dputs "Handling cancel"
1394 if {$delayRequest != ""} {
1400 if {$toget > 0 && $m > 1 && $m < $toget} {
1401 set ntoget [expr $toget - $m + 1]
1402 dputs ntoget=$ntoget
1403 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1405 dputs "down continue: $q"
1407 z39.scan numberOfTermsRequested 10
1409 z39.scan numberOfTermsRequested $ntoget
1411 z39.scan preferredPositionInResponse 1
1412 dputs "${attr} \{$q\}"
1413 z39.scan scan "${attr} \{$q\}"
1416 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1417 set ntoget [expr - $toget - $m]
1418 dputs ntoget=$ntoget
1419 z39 callback [list scan-response $attr 0 -$ntoget]
1420 set q [string range [$w.top.list get 0] 8 end]
1421 dputs "up continue: $q"
1423 z39.scan numberOfTermsRequested 10
1424 z39.scan preferredPositionInResponse 11
1426 z39.scan numberOfTermsRequested $ntoget
1427 z39.scan preferredPositionInResponse [incr ntoget]
1429 dputs "${attr} \{$q\}"
1430 z39.scan scan "${attr} \{$q\}"
1433 show-status Ready 0 1
1436 proc scan-down {attr} {
1444 show-status {Scanning down} 1 0
1445 set delayRequest [list scan-down $attr]
1451 set scanView [expr $scanView + 5]
1452 set s [$w.top.list size]
1453 if {$scanView > $s} {
1454 z39 callback [list scan-response $attr [expr $s - 1] 25]
1455 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1457 z39.scan numberOfTermsRequested 10
1458 z39.scan preferredPositionInResponse 1
1459 show-status Scanning 1 0
1460 dputs "${attr} \{$q\}"
1461 z39.scan scan "${attr} \{$q\}"
1464 $w.top.list yview $scanView
1467 proc scan-up {attr} {
1475 show-status Scanning 1 0
1476 set delayRequest [list scan-up $attr]
1482 set scanView [expr $scanView - 5]
1483 if {$scanView < 0} {
1484 z39 callback [list scan-response $attr 0 -25]
1485 set q [string range [$w.top.list get 0] 8 end]
1487 z39.scan numberOfTermsRequested 10
1488 z39.scan preferredPositionInResponse 11
1489 show-status Scanning 1 0
1490 z39.scan scan "${attr} \{$q\}"
1493 $w.top.list yview $scanView
1496 proc search-response {} {
1506 dputs "In search-response"
1508 dputs "Handling cancel"
1510 if {$delayRequest != ""} {
1518 set setMax [z39.$setNo resultCount]
1519 show-status Ready 0 1
1520 set status [z39.$setNo responseStatus]
1521 if {[lindex $status 0] == "NSD"} {
1522 z39.$setNo nextResultSetPosition 0
1523 set code [lindex $status 1]
1524 set msg [lindex $status 2]
1525 set addinfo [lindex $status 3]
1526 tkerror "NSD$code: $msg: $addinfo"
1529 show-message "${setMax} hits"
1534 show-status Ready 0 1
1535 set l [format "%-4d %7d" $setNo $setMax]
1536 .top.rset.m add command -label $l \
1537 -command [list add-title-lines $setNo 10000 1]
1541 set no [z39.$setNo numberOfRecordsReturned]
1542 dputs "Returned $no records, setOffset $setOffset"
1543 add-title-lines $setNo $no $setOffset
1544 set setOffset [expr $setOffset + $no]
1546 set toGet [expr $setMax - $setOffset + 1]
1548 if {$setOffset == 1} {
1550 } elseif {$toGet > $presentChunk} {
1551 set toGet $presentChunk
1553 z39 callback {present-response}
1554 z39.$setNo present $setOffset $toGet
1555 show-status Retrieving 1 0
1559 proc present-more {number} {
1568 dputs "present-more"
1570 show-status Retrieving 1 0
1571 set delayRequest "present-more $number"
1577 dputs "setNo=$setNo"
1580 set setOffset [z39.$setNo nextResultSetPosition]
1581 dputs "setOffest=${setOffset}"
1582 dputs "setNo=${setNo}"
1583 set max [z39.$setNo resultCount]
1584 if {$max < $setOffset} {
1586 dputs "setOffset=$setOffset"
1587 show-status Ready 0 1
1590 if {$number == ""} {
1594 if {$setMax > $max} {
1598 z39 callback {present-response}
1600 set toGet [expr $setMax - $setOffset + 1]
1604 if {$toGet > $presentChunk} {
1605 set toGet $presentChunk
1607 z39.$setNo present $setOffset $toGet
1608 show-status Retrieving 1 0
1611 proc init-title-lines {} {
1612 .data.record delete 0.0 end
1615 proc add-title-lines {setno no offset} {
1616 global displayFormats
1617 global displayFormat
1621 dputs "add-title-lines offset=${offset} no=${no}"
1629 .bot.a.set configure -text $setno
1630 .data.record delete 0.0 end
1632 set ffunc [lindex $displayFormats $displayFormat]
1633 dputs "ffunc=$ffunc"
1634 set ffunc "display-$ffunc"
1635 for {set i 0} {$i < $no} {incr i} {
1636 set o [expr $i + $offset]
1637 set type [z39.$setno type $o]
1639 dputs "no more at $o"
1642 .data.record tag bind r$o <Any-Enter> {}
1643 .data.record tag bind r$o <Any-Leave> {}
1644 set insert0 [.data.record index insert]
1645 $ffunc $setno $o .data.record 1
1646 .data.record tag add r$o $insert0 insert
1647 .data.record tag bind r$o <1> \
1648 [list popup-marc $setno $o 0 0]
1652 show-status Ready 0 1
1656 proc present-response {} {
1664 dputs "In present-response"
1665 set no [z39.$setNo numberOfRecordsReturned]
1666 dputs "Returned $no records, setOffset $setOffset"
1667 add-title-lines $setNo $no $setOffset
1668 set setOffset [expr $setOffset + $no]
1670 dputs "Handling cancel"
1672 if {$delayRequest != ""} {
1677 set status [z39.$setNo responseStatus]
1678 if {[lindex $status 0] == "NSD"} {
1679 show-status Ready 0 1
1680 set code [lindex $status 1]
1681 set msg [lindex $status 2]
1682 set addinfo [lindex $status 3]
1683 tkerror "NSD$code: $msg: $addinfo"
1686 if {$no > 0 && $setOffset <= $setMax} {
1687 dputs "present-request from ${setOffset}"
1688 set toGet [expr $setMax - $setOffset + 1]
1689 if {$toGet > $presentChunk} {
1690 set toGet $presentChunk
1692 z39.$setNo present $setOffset $toGet
1694 show-status Ready 0 1
1698 proc left-cursor {w} {
1699 set i [$w index insert]
1707 proc right-cursor {w} {
1708 set i [$w index insert]
1714 proc bind-fields {list returnAction escapeAction} {
1715 set max [expr [llength $list]-1]
1716 for {set i 0} {$i < $max} {incr i} {
1717 bind [lindex $list $i] <Return> $returnAction
1718 bind [lindex $list $i] <Escape> $escapeAction
1720 bind [lindex $list $i] <Tab> \
1721 [list focus [lindex $list [expr $i+1]]]
1722 bind [lindex $list $i] <Left> \
1723 [list left-cursor [lindex $list $i]]
1724 bind [lindex $list $i] <Right> \
1725 [list right-cursor [lindex $list $i]]
1728 bind [lindex $list $i] <Return> $returnAction
1729 bind [lindex $list $i] <Escape> $escapeAction
1731 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1732 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1733 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1735 focus [lindex $list 0]
1738 proc entry-fields {parent list tlist returnAction escapeAction} {
1741 foreach field $list {
1742 set label ${parent}.${field}.label
1743 set entry ${parent}.${field}.entry
1744 label $label -text [lindex $tlist $i] -anchor e
1745 entry $entry -width 32 -relief sunken
1746 pack $label -side left
1747 pack $entry -side right
1748 lappend alist $entry
1751 bind-fields $alist $returnAction $escapeAction
1754 proc define-target-dialog {} {
1755 set w .target-define
1761 pack $w.top.target \
1762 -side top -anchor e -pady 2
1763 entry-fields $w.top {target} \
1765 {define-target-action} {destroy .target-define}
1766 top-down-ok-cancel $w {define-target-action} 1
1769 proc protocol-setup-delete {target w} {
1771 global settingsChanged
1773 set a [alert "Are you sure you want to delete the target \
1774 definition $target ?"]
1777 unset profile($target)
1778 set settingsChanged 1
1780 delete-target-hotlist $target
1784 proc protocol-setup-action {target w} {
1786 global settingsChanged
1790 set settingsChanged 1
1791 set len [$w.top.databases.list size]
1792 for {set i 0} {$i < $len} {incr i} {
1793 lappend dataBases [$w.top.databases.list get $i]
1795 set wno [lindex $profile($target) 12]
1797 set profile($target) [list [$w.top.description.entry get] \
1798 [$w.top.host.entry get] \
1799 [$w.top.port.entry get] \
1800 [$w.top.idAuthentication.entry get] \
1801 $targetS($target,MRS) \
1802 $targetS($target,PMS) \
1803 $targetS($target,csType) \
1805 $targetS($target,RPN) \
1806 $targetS($target,CCL) \
1807 $targetS($target,ResultSets) \
1808 $targetS($target,protocolType) \
1810 $targetS($target,LSLB) \
1811 $targetS($target,SSUB) \
1812 $targetS($target,MSPN) \
1813 $targetS($target,presentChunk) ]
1816 delete-target-hotlist $target
1817 dputs $profile($target)
1821 proc place-force {window parent} {
1822 set g [wm geometry $parent]
1824 set p1 [string first + $g]
1825 set p2 [string last + $g]
1827 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1828 set y [expr 60+[string range $g [expr $p2 +1] end]]
1829 wm geometry $window +${x}+${y}
1832 proc add-database-action {target w} {
1835 $w.top.databases.list insert end \
1836 [.database-select.top.database.entry get]
1837 destroy .database-select
1840 proc add-database {target wp} {
1843 set w .database-select
1845 set oldFocus [focus]
1851 frame $w.top.database
1853 pack $w.top.database -side top -anchor e -pady 2
1855 entry-fields $w.top {database} \
1856 {{Database to add:}} \
1857 [list add-database-action $target $wp] {destroy .database-select}
1859 top-down-ok-cancel $w [list add-database-action $target $wp] 1
1863 proc delete-database {target w} {
1867 foreach i [$w.top.databases.list curselection] {
1868 set b [$w.top.databases.list get $i]
1871 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1873 foreach i [lsort -decreasing \
1874 [$w.top.databases.list curselection]] {
1875 $w.top.databases.list delete $i
1880 proc protocol-setup {target} {
1885 while {[winfo exists .setup-$bno]} {
1892 wm title $w "Setup $target"
1896 if {$target == ""} {
1900 dputs $profile($target)
1902 frame $w.top.description
1905 frame $w.top.idAuthentication
1906 frame $w.top.cs-type -relief ridge -border 2
1907 frame $w.top.protocol -relief ridge -border 2
1908 frame $w.top.query -relief ridge -border 2
1909 frame $w.top.databases -relief ridge -border 2
1911 # Maximum/preferred/idAuth ...
1912 pack $w.top.description $w.top.host $w.top.port \
1913 $w.top.idAuthentication -side top -anchor e -pady 2
1915 entry-fields $w.top {description host port idAuthentication } \
1916 {{Description:} {Host:} {Port:} {Id Authentication:}} \
1917 [list protocol-setup-action $target $w] [list destroy $w]
1919 foreach sub {description host port idAuthentication} {
1921 bind $w.top.$sub.entry <Control-a> [list add-database $target $w]
1922 bind $w.top.$sub.entry <Control-d> [list delete-database $target $w]
1924 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1925 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1926 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1927 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1928 set targetS($target,csType) [lindex $profile($target) 6]
1929 set targetS($target,RPN) [lindex $profile($target) 8]
1930 set targetS($target,CCL) [lindex $profile($target) 9]
1931 set targetS($target,ResultSets) [lindex $profile($target) 10]
1932 set targetS($target,protocolType) [lindex $profile($target) 11]
1933 if {$targetS($target,protocolType) == ""} {
1934 set targetS($target,protocolType) Z39
1936 set targetS($target,LSLB) [lindex $profile($target) 13]
1937 set targetS($target,SSUB) [lindex $profile($target) 14]
1938 set targetS($target,MSPN) [lindex $profile($target) 15]
1939 set targetS($target,presentChunk) [lindex $profile($target) 16]
1940 set targetS($target,MRS) [lindex $profile($target) 4]
1941 set targetS($target,PMS) [lindex $profile($target) 5]
1943 pack $w.top.databases -side left -pady 2 -padx 2 -expand yes -fill both
1945 label $w.top.databases.label -text "Databases"
1946 button $w.top.databases.add -text Add \
1947 -command [list add-database $target $w]
1948 button $w.top.databases.delete -text Delete \
1949 -command [list delete-database $target $w]
1951 listbox $w.top.databases.list -geometry 14x6 \
1952 -yscrollcommand "$w.top.databases.scroll set"
1954 listbox $w.top.databases.list -width 14 -height 5\
1955 -yscrollcommand "$w.top.databases.scroll set"
1957 scrollbar $w.top.databases.scroll -orient vertical -border 1
1958 pack $w.top.databases.label -side top -fill x \
1960 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1962 pack $w.top.databases.list -side left -fill both -expand yes \
1964 pack $w.top.databases.scroll -side right -fill y \
1966 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1968 foreach b [lindex $profile($target) 7] {
1969 $w.top.databases.list insert end $b
1973 pack $w.top.cs-type -pady 2 -padx 2 -side top -fill x
1975 label $w.top.cs-type.label -text "Transport"
1976 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1977 -variable targetS($target,csType) -value tcpip
1978 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1979 -variable targetS($target,csType) -value mosi
1981 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1982 -padx 2 -side top -fill x
1985 pack $w.top.protocol -pady 2 -padx 2 -side top -fill x
1987 label $w.top.protocol.label -text "Protocol"
1988 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1989 -variable targetS($target,protocolType) -value Z39
1990 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1991 -variable targetS($target,protocolType) -value SR
1993 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1994 -padx 2 -side top -fill x
1997 pack $w.top.query -pady 2 -padx 2 -side top -fill x
1999 label $w.top.query.label -text "Query support"
2000 checkbutton $w.top.query.c1 -text "RPN query" -anchor w \
2001 -variable targetS($target,RPN)
2002 checkbutton $w.top.query.c2 -text "CCL query" -anchor w \
2003 -variable targetS($target,CCL)
2004 checkbutton $w.top.query.c3 -text "Result sets" -anchor w \
2005 -variable targetS($target,ResultSets)
2007 pack $w.top.query.label -side top
2008 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
2009 -padx 2 -side top -fill x
2012 bottom-buttons $w [list {Ok} [list protocol-setup-action $target $w] \
2013 {Delete} [list protocol-setup-delete $target $w] \
2014 {Advanced} [list advanced-setup $target $bno] \
2015 {Cancel} [list destroy $w]] 0
2019 proc advanced-setup {target b} {
2023 set w .advanced-setup-$b
2027 wm title $w "Advanced setup $target"
2031 if {$target == ""} {
2036 frame $w.top.largeSetLowerBound
2037 frame $w.top.smallSetUpperBound
2038 frame $w.top.mediumSetPresentNumber
2039 frame $w.top.presentChunk
2040 frame $w.top.maximumRecordSize
2041 frame $w.top.preferredMessageSize
2043 pack $w.top.largeSetLowerBound $w.top.smallSetUpperBound \
2044 $w.top.mediumSetPresentNumber $w.top.presentChunk \
2045 $w.top.maximumRecordSize $w.top.preferredMessageSize \
2046 -side top -anchor e -pady 2
2048 entry-fields $w.top {largeSetLowerBound smallSetUpperBound \
2049 mediumSetPresentNumber presentChunk maximumRecordSize \
2050 preferredMessageSize} \
2051 {{Large Set Lower Bound:} {Small Set Upper Bound:} \
2052 {Medium Set Present Number:} {Present Chunk:} \
2053 {Maximum Record Size:} {Preferred Message Size:}} \
2054 [list advanced-setup-action $target $b] [list destroy $w]
2056 $w.top.largeSetLowerBound.entry insert 0 $targetS($target,LSLB)
2057 $w.top.smallSetUpperBound.entry insert 0 $targetS($target,SSUB)
2058 $w.top.mediumSetPresentNumber.entry insert 0 $targetS($target,MSPN)
2059 $w.top.presentChunk.entry insert 0 $targetS($target,presentChunk)
2060 $w.top.maximumRecordSize.entry insert 0 $targetS($target,MRS)
2061 $w.top.preferredMessageSize.entry insert 0 $targetS($target,PMS)
2063 bottom-buttons $w [list {Ok} [list advanced-setup-action $target $b] \
2064 {Cancel} [list destroy $w]] 0
2067 proc advanced-setup-action {target b} {
2068 set w .advanced-setup-$b
2071 set targetS($target,LSLB) [$w.top.largeSetLowerBound.entry get]
2072 set targetS($target,SSUB) [$w.top.smallSetUpperBound.entry get]
2073 set targetS($target,MSPN) [$w.top.mediumSetPresentNumber.entry get]
2074 set targetS($target,presentChunk) [$w.top.presentChunk.entry get]
2075 set targetS($target,MRS) [$w.top.maximumRecordSize.entry get]
2076 set targetS($target,PMS) [$w.top.preferredMessageSize.entry get]
2078 dputs "advanced-setup-action"
2082 proc database-select-action {} {
2083 set w .database-select.top
2085 foreach indx [$w.databases.list curselection] {
2086 lappend b [$w.databases.list get $indx]
2089 z39 databaseNames $b
2091 destroy .database-select
2094 proc database-select {} {
2095 set w .database-select
2100 set oldFocus [focus]
2105 frame $w.top.databases -relief ridge -border 2
2107 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
2109 label $w.top.databases.label -text "List"
2110 listbox $w.top.databases.list -width 20 -height 6 \
2111 -yscrollcommand "$w.top.databases.scroll set"
2112 scrollbar $w.top.databases.scroll -orient vertical -border 1
2113 pack $w.top.databases.label -side top -fill x \
2115 pack $w.top.databases.list -side left -fill both -expand yes \
2117 pack $w.top.databases.scroll -side right -fill y \
2119 $w.top.databases.scroll config -command "$w.top.databases.list yview"
2121 foreach b [lindex $profile($hostid) 7] {
2122 $w.top.databases.list insert end $b
2124 top-down-ok-cancel $w {database-select-action} 1
2128 proc cascade-target-list {} {
2131 foreach sub [winfo children .top.target.m.clist] {
2134 .top.target.m.clist delete 0 last
2135 foreach n [lsort [array names profile]] {
2136 if {$n != "Default"} {
2137 set nl [lindex $profile($n) 12]
2138 if {[llength [lindex $profile($n) 7]] > 1} {
2139 .top.target.m.clist add cascade -label $n \
2140 -menu .top.target.m.clist.$nl
2141 menu .top.target.m.clist.$nl
2142 foreach b [lindex $profile($n) 7] {
2143 .top.target.m.clist.$nl add command -label $b \
2144 -command [list reopen-target $n $b]
2147 .top.target.m.clist add command -label $n \
2148 -command [list reopen-target $n {}]
2152 .top.target.m.slist delete 0 last
2153 foreach n [lsort [array names profile]] {
2154 .top.target.m.slist add command -label $n \
2155 -command [list protocol-setup $n]
2159 proc query-select {i} {
2160 global queryButtonsFind
2161 global queryInfoFind
2165 set queryInfoFind [lindex $queryInfo $i]
2166 set queryButtonsFind [lindex $queryButtons $i]
2168 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2171 proc query-new-action {} {
2175 global settingsChanged
2177 set settingsChanged 1
2178 lappend queryTypes [.query-new.top.index.entry get]
2179 lappend queryButtons {}
2180 lappend queryInfo {}
2190 set oldFocus [focus]
2195 -side top -anchor e -pady 2
2196 entry-fields $w.top index \
2198 query-new-action {destroy .query-new}
2199 top-down-ok-cancel $w query-new-action 1
2203 proc query-delete-action {queryNo} {
2207 global settingsChanged
2209 set settingsChanged 1
2211 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
2212 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
2213 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
2214 destroy .query-delete
2218 proc query-delete {queryNo} {
2226 set n [lindex $queryTypes $queryNo]
2228 label $w.top.warning -bitmap warning
2229 message $w.top.quest -text "Are you sure you want to delete the \
2230 query type $n ?" -aspect 300
2231 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
2232 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
2233 {Cancel} [list destroy $w]] 1
2236 proc cascade-query-list {} {
2238 set w .top.options.m.query
2241 $w.slist delete 0 last
2242 foreach n $queryTypes {
2243 $w.slist add command -label $n -command [list query-setup $i]
2248 $w.clist delete 0 last
2249 foreach n $queryTypes {
2250 $w.clist add command -label $n -command [list query-select $i]
2254 $w.dlist delete 0 last
2255 foreach n $queryTypes {
2256 $w.dlist add command -label $n -command [list query-delete $i]
2261 proc save-geometry {} {
2262 global windowGeometry
2265 global displayFormat
2268 global elementSetNames
2271 set windowGeometry(.) [wm geometry .]
2273 if {[catch {set f [open ~/.clientrc.tcl w]}]} {
2276 if {$hostid != "Default"} {
2277 puts $f "set hostid \{$hostid\}"
2278 set b [z39 databaseNames]
2279 puts $f "set hostbase $b"
2281 puts $f "set hotTargets \{ $hotTargets \}"
2282 puts $f "set textWrap $textWrap"
2283 puts $f "set displayFormat $displayFormat"
2284 puts $f "set popupMarcdf $popupMarcdf"
2285 puts $f "set recordSyntax $recordSyntax"
2286 puts $f "set elementSetNames $elementSetNames"
2287 foreach n [array names windowGeometry] {
2288 puts -nonewline $f "set \{windowGeometry($n)\} \{"
2289 puts -nonewline $f $windowGeometry($n)
2295 proc save-settings {} {
2298 global settingsChanged
2303 if {![file writable "${libdir}/clientrc.tcl"]} {
2304 set a [alert "Cannot open ${libdir}/clientrc.tcl for writing. Do you \
2305 wish to save clientrc.tcl in the current directory instead?"]
2309 set f [open "clientrc.tcl" w]
2311 set f [open "${libdir}/clientrc.tcl" w]
2313 puts $f "# Setup file"
2315 foreach n [array names profile] {
2316 puts -nonewline $f "set \{profile($n)\} \{"
2317 puts -nonewline $f $profile($n)
2320 puts -nonewline $f "set queryTypes \{"
2321 puts -nonewline $f $queryTypes
2324 puts -nonewline $f "set queryButtons \{"
2325 puts -nonewline $f $queryButtons
2328 puts -nonewline $f "set queryInfo \{"
2329 puts -nonewline $f $queryInfo
2332 set settingsChanged 0
2341 set oldFocus [focus]
2345 label $w.top.warning -bitmap warning
2346 message $w.top.message -text $ask -aspect 300 \
2347 -font -Adobe-Times-Medium-R-Normal-*-180-*
2349 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
2352 top-down-ok-cancel $w {alert-action} 1
2357 proc alert-action {} {
2363 proc exit-action {} {
2364 global settingsChanged
2366 if {$settingsChanged} {
2367 set a [alert "you haven't saved your settings. Do you wish to save?"]
2376 proc listbuttonaction {w name h user i} {
2377 $w configure -text [lindex $name 0]
2378 $h [lindex $name 1] $user $i
2381 proc listbuttonx {button no names handle user} {
2382 if {[winfo exists $button]} {
2383 $button configure -text [lindex [lindex $names $no] 0]
2384 ${button}.m delete 0 last
2386 menubutton $button -text [lindex [lindex $names $no] 0] \
2387 -width 10 -menu ${button}.m -relief raised -border 1
2391 foreach name $names {
2392 ${button}.m add command -label [lindex $name 0] \
2393 -command [list listbuttonaction ${button} $name \
2399 proc listbutton {button no names} {
2400 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
2401 -relief raised -border 1
2403 foreach name $names {
2404 ${button}.m add command -label $name \
2405 -command [list ${button} configure -text $name]
2409 proc listbuttonv-action {button var names i} {
2412 set $var [lindex $names [expr $i+1]]
2413 $button configure -text [lindex $names $i]
2416 proc listbuttonv {button var names} {
2420 eval "set val $$var"
2421 set l [llength $names]
2422 for {set i 1} {$i < $l} {incr i 2} {
2423 if {$val == [lindex $names $i]} {
2425 set n [lindex $names $i]
2429 if {[winfo exists $button]} {
2430 $button configure -text $n
2433 menubutton $button -text $n -menu ${button}.m \
2434 -relief raised -border 1
2436 for {set i 0} {$i < $l} {incr i 2} {
2437 ${button}.m add command -label [lindex $names $i] \
2438 -command [list listbuttonv-action $button $var $names $i]
2442 proc query-add-index-action {queryNo} {
2446 global queryButtonsTmp
2448 set newI [.query-add-index.top.index.entry get]
2449 lappend queryInfoTmp [list $newI {}]
2450 $w.top.index.list insert end $newI
2451 destroy .query-add-index
2452 #destroy $w.top.lines
2453 #frame $w.top.lines -relief ridge -border 2
2454 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2455 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2458 proc query-add-line {queryNo} {
2462 global queryButtonsTmp
2464 lappend queryButtonsTmp {I 0}
2466 #destroy $w.top.lines
2467 #frame $w.top.lines -relief ridge -border 2
2468 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2469 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2472 proc query-del-line {queryNo} {
2476 global queryButtonsTmp
2478 set l [llength $queryButtonsTmp]
2483 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
2484 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2487 proc query-add-index {queryNo} {
2488 set w .query-add-index
2491 set oldFocus [focus]
2492 place-force $w .query-setup
2496 -side top -anchor e -pady 2
2497 entry-fields $w.top {index} \
2499 [list query-add-index-action $queryNo] [list destroy $w]
2500 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
2504 proc query-setup-action {queryNo} {
2507 global queryButtonsTmp
2509 global queryButtonsFind
2510 global queryInfoFind
2512 global settingsChanged
2514 set settingsChanged 1
2516 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
2518 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
2520 set queryInfoFind $queryInfoTmp
2521 set queryButtonsFind $queryButtonsTmp
2523 destroy .query-setup
2524 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2527 proc activate-e-index {value no i} {
2528 global queryButtonsTmp
2529 global queryIndexTmp
2531 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
2532 dputs $queryButtonsTmp
2533 set queryIndexTmp $i
2536 proc activate-index {value no i} {
2537 global queryButtonsFind
2539 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
2541 dputs "queryButtonsFind $queryButtonsFind"
2544 proc update-attr {} {
2546 listbuttonv $w.top.relation.b relationTmpValue\
2547 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
2548 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
2549 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
2550 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
2551 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
2552 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
2553 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
2554 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
2555 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
2556 {local-number} 107 {string} 108 {numeric string} 109}
2557 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2558 {Left} 2 {Left and right} 3 {No truncation} 100 \
2559 {Process #} 101 {Re-1} 102 {Re-2} 103}
2560 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2561 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2564 proc use-attr {init} {
2576 {BNB card number} 10
2577 {BGF(sic) number} 11
2579 {Dewey classification} 13
2580 {UDC classification} 14
2581 {Bliss classification} 15
2583 {NLM call number} 17
2584 {NAL call number} 18
2585 {MOS call number} 19
2586 {Local classification} 20
2587 {Subject heading} 21
2589 {BDI-index-subject} 23
2593 {LC-subject-heading} 27
2594 {RVM-subject-heading} 28
2595 {Local subject index} 29
2597 {Date of publication} 31
2598 {Date of acquisition} 32
2600 {Title-collective} 34
2603 {Title-added-title-page} 37
2607 {Title-other-variant} 41
2609 {Title-abbreviated} 43
2613 {Subject-subdivision} 47
2614 {Number-natl-bibliography} 48
2615 {Number-legal-deposit} 49
2616 {Number-govt-publication} 50
2617 {Number-publisher-for-music} 51
2619 {Number-local-call} 53
2621 {Code-geographic-area} 55
2622 {Code-institution} 56
2624 {Name-geographic} 58
2625 {Place-publication} 59
2627 {Microform-generation} 61
2634 {Author-name-personal} 1004
2635 {Author-name-corporate} 1005
2636 {Author-name-conference} 1006
2637 {Identifier-standard} 1007
2638 {Subject-LC-children's} 1008
2639 {Subject-name-personal} 1009
2641 {Date/time added to database} 1011
2642 {Date/time last modified} 1012
2643 {Authority/format identifier} 1013
2645 {Concept-reference} 1015
2647 {Server choice} 1017
2649 {Record source} 1019
2652 {Geographic class} 1022
2656 {Related periodical} 1026
2657 {Report number} 1027
2659 {Thematic number} 1030
2660 {Material type} 1031
2668 set l [llength $attr]
2673 for {set i 0} {$i < $l} {incr i} {
2674 $w.top.use.list insert end [lindex $attr $i]
2676 if {$useTmpValue == [lindex $attr $i]} {
2682 $w.top.use.list selection clear 0 end
2683 $w.top.use.list selection set $s $s
2685 $w.top.use.list select from $s
2686 $w.top.use.list select to $s
2692 $w.top.use.list yview $s
2694 set lno [lindex [$w.top.use.list curselection] 0]
2695 set i [expr $lno+$lno+1]
2696 set useTmpValue [lindex $attr $i]
2697 dputs "useTmpValue=$useTmpValue"
2701 proc index-setup-action {oldAttr queryNo indexNo} {
2702 set attr [lindex $oldAttr 0]
2705 global relationTmpValue
2706 global structureTmpValue
2707 global truncationTmpValue
2708 global completenessTmpValue
2709 global positionTmpValue
2714 dputs "index-setup-action"
2715 dputs "queryNo $queryNo"
2716 dputs "indexNo $indexNo"
2717 if {$useTmpValue > 0} {
2718 lappend attr "1=$useTmpValue"
2720 if {$relationTmpValue > 0} {
2721 lappend attr "2=$relationTmpValue"
2723 if {$positionTmpValue > 0} {
2724 lappend attr "3=$positionTmpValue"
2726 if {$structureTmpValue > 0} {
2727 lappend attr "4=$structureTmpValue"
2729 if {$truncationTmpValue > 0} {
2730 lappend attr "5=$truncationTmpValue"
2732 if {$completenessTmpValue > 0} {
2733 lappend attr "6=$completenessTmpValue"
2735 dputs "new attr $attr"
2736 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2737 destroy .index-setup
2740 proc index-setup {attr queryNo indexNo} {
2743 global relationTmpValue
2744 global structureTmpValue
2745 global truncationTmpValue
2746 global completenessTmpValue
2747 global positionTmpValue
2749 set relationTmpValue 0
2750 set truncationTmpValue 0
2751 set structureTmpValue 0
2752 set positionTmpValue 0
2753 set completenessTmpValue 0
2759 set n [lindex $attr 0]
2760 wm title $w "Index setup $n"
2764 set len [llength $attr]
2765 for {set i 1} {$i < $len} {incr i} {
2766 set q [lindex $attr $i]
2767 set l [string first = $q]
2769 set t [string range $q 0 [expr $l - 1]]
2770 set v [string range $q [expr $l + 1] end]
2773 { set useTmpValue $v }
2775 { set relationTmpValue $v }
2777 { set positionTmpValue $v }
2779 { set structureTmpValue $v }
2781 { set truncationTmpValue $v }
2783 { set completenessTmpValue $v }
2788 frame $w.top.use -relief ridge -border 2
2789 frame $w.top.relation -relief ridge -border 2
2790 frame $w.top.position -relief ridge -border 2
2791 frame $w.top.structure -relief ridge -border 2
2792 frame $w.top.truncation -relief ridge -border 2
2793 frame $w.top.completeness -relief ridge -border 2
2799 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2801 label $w.top.use.label -text "Use"
2803 listbox $w.top.use.list -width 26 \
2804 -yscrollcommand "$w.top.use.scroll set"
2806 listbox $w.top.use.list -geometry 26x10 \
2807 -yscrollcommand "$w.top.use.scroll set"
2809 scrollbar $w.top.use.scroll -orient vertical -border 1
2810 pack $w.top.use.label -side top -fill x \
2812 pack $w.top.use.list -side left -fill both -expand yes \
2814 pack $w.top.use.scroll -side right -fill y \
2816 $w.top.use.scroll config -command "$w.top.use.list yview"
2820 # Relation Attributes
2822 pack $w.top.relation -pady 6 -padx 6 -side top
2823 label $w.top.relation.label -text "Relation" -width 18
2825 pack $w.top.relation.label $w.top.relation.b -fill x
2827 # Position Attributes
2829 pack $w.top.position -pady 6 -padx 6 -side top
2830 label $w.top.position.label -text "Position" -width 18
2832 pack $w.top.position.label $w.top.position.b -fill x
2834 # Structure Attributes
2836 pack $w.top.structure -pady 6 -padx 6 -side top
2837 label $w.top.structure.label -text "Structure" -width 18
2839 pack $w.top.structure.label $w.top.structure.b -fill x
2841 # Truncation Attributes
2843 pack $w.top.truncation -pady 6 -padx 6 -side top
2844 label $w.top.truncation.label -text "Truncation" -width 18
2846 pack $w.top.truncation.label $w.top.truncation.b -fill x
2848 # Completeness Attributes
2850 pack $w.top.completeness -pady 6 -padx 6 -side top
2851 label $w.top.completeness.label -text "Completeness" -width 18
2853 pack $w.top.completeness.label $w.top.completeness.b -fill x
2856 bottom-buttons $w [list \
2857 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2858 {Cancel} [list destroy $w]] 0
2862 proc query-edit-index {queryNo} {
2866 set i [lindex [$w.top.index.list curselection] 0]
2870 set attr [lindex $queryInfoTmp $i]
2871 dputs "Editing no $i $attr"
2872 index-setup $attr $queryNo $i
2875 proc query-delete-index {queryNo} {
2877 global queryButtonsTmp
2880 set i [lindex [$w.top.index.list curselection] 0]
2884 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2885 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2886 $w.top.index.list delete $i
2889 proc query-setup {queryNo} {
2895 global queryButtonsTmp
2897 global queryIndexTmp
2900 set queryName [lindex $queryTypes $queryNo]
2901 set queryInfoTmp [lindex $queryInfo $queryNo]
2902 set queryButtonsTmp [lindex $queryButtons $queryNo]
2907 wm title $w "Query setup $queryName"
2911 frame $w.top.lines -relief ridge -border 2
2913 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2917 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2919 button $w.top.lines.add -text "Add" \
2920 -command [list query-add-line $queryNo]
2921 button $w.top.lines.del -text "Remove" \
2922 -command [list query-del-line $queryNo]
2924 pack $w.top.lines.del -fill x -side bottom
2925 pack $w.top.lines.add -fill x -pady 10 -side bottom
2929 frame $w.top.index -relief ridge -border 2
2930 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2932 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2933 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2934 -command [list $w.top.index.list yview]
2935 bind $w.top.index.list <Double-1> [list query-edit-index $queryNo]
2937 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2938 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2941 $w.top.index.list selection clear 0 end
2942 $w.top.index.list selection set 0 0
2944 $w.top.index.list select from 0
2945 $w.top.index.list select to 0
2948 foreach x $queryInfoTmp {
2949 $w.top.index.list insert end [lindex $x 0]
2953 bottom-buttons $w [list \
2954 Ok [list query-setup-action $queryNo] \
2955 Add [list query-add-index $queryNo] \
2956 Edit [list query-edit-index $queryNo] \
2957 Delete [list query-delete-index $queryNo] \
2958 Cancel [list destroy $w]] 0
2961 proc index-clear {} {
2962 global queryButtonsFind
2965 foreach b $queryButtonsFind {
2966 .lines.$i.e delete 0 end
2971 proc index-query {} {
2972 global queryButtonsFind
2973 global queryInfoFind
2978 foreach b $queryButtonsFind {
2979 set term [string trim [.lines.$i.e get]]
2981 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
2984 set len [string length $term]
2988 if {[string index $term 0] == ">"} {
2989 if {[string index $term 1] == "=" } {
2990 set term [string trim [string range $term 2 $len]]
2993 set term [string trim [string range $term 1 $len]]
2996 } elseif {[string index $term 0] == "<"} {
2997 if {[string index $term 1] == "=" } {
2998 set term [string trim [string range $term 2 $len]]
3000 } elseif {[string index $term 1] == ">"} {
3001 set term [string trim [string range $term 2 $len]]
3004 set term [string trim [string range $term 1 $len]]
3009 set len [string length $term]
3013 if {[string index $term $len] == "?"} {
3015 set term [string range $term 0 [expr $len - 1]]
3017 if {[string index $term 0] == "?"} {
3019 set term [string range $term 1 end]
3021 set term "\{${term}\}"
3022 if {$right && $left} {
3023 set term "@attr 5=3 ${term}"
3025 set term "@attr 5=1 ${term}"
3027 set term "@attr 5=2 ${term}"
3029 if {$relation != ""} {
3030 set term "@attr 2=${relation} ${term}"
3033 set term "@attr $a ${term}"
3036 set qs "@and ${qs} ${term}"
3047 proc index-focus-in {w i} {
3048 global curIndexEntry
3051 $w.$i configure -background red
3053 set curIndexEntry $i
3056 proc index-lines {w realOp buttonInfo queryInfo handle} {
3058 foreach b $buttonInfo {
3059 if {! [winfo exists $w.$i]} {
3061 frame $w.$i -border 0
3063 frame $w.$i -background white -border 1
3066 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
3069 if {! [winfo exists $w.$i.e]} {
3070 entry $w.$i.e -width 32 -relief sunken -border 1
3071 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
3072 bind $w.$i.e <FocusOut> [list $w.$i configure \
3074 pack $w.$i.l -side left
3075 pack $w.$i.e -side left -fill x -expand yes
3076 pack $w.$i -side top -fill x -padx 2 -pady 2
3078 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
3079 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
3081 bind $w.$i.e <Return> {search-request 0}
3084 pack $w.$i.l -side left
3085 pack $w.$i -side top -fill x -padx 2 -pady 2
3090 while {[winfo exists $w.$j]} {
3102 bind $w.$j.e <Tab> "focus $w.$k.e"
3108 bind $w.$i.e <Tab> "focus $w.0.e"
3114 proc search-fields {w buttondefs} {
3116 foreach buttondef $buttondefs {
3117 frame $w.$i -background white
3119 listbutton $w.$i.l 0 $buttondef
3120 entry $w.$i.e -width 32 -relief sunken
3122 pack $w.$i.l -side left
3123 pack $w.$i.e -side left -fill x -expand yes
3125 pack $w.$i -side top -fill x -padx 2 -pady 2
3127 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
3128 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
3136 bind $w.$j.e <Tab> "focus $w.$k.e \n
3137 $w.$k configure -background red \n
3138 $w.$j configure -background white"
3141 bind $w.$i.e <Tab> "focus $w.0.e \n
3142 $w.0 configure -background red \n
3143 $w.$i configure -background white"
3145 $w.0 configure -background red
3148 if {[info exists windowGeometry(.)]} {
3149 set g $windowGeometry(.)
3157 frame .top -border 1 -relief raised
3158 frame .lines -border 1 -relief raised
3159 frame .mid -border 1 -relief raised
3160 frame .data -border 1 -relief raised
3161 frame .bot -border 1 -relief raised
3162 pack .top .lines .mid -side top -fill x
3163 pack .data -side top -fill both -expand yes
3166 menubutton .top.file -text "File" -menu .top.file.m
3168 .top.file.m add command -label "Save settings" -command {save-settings}
3169 .top.file.m add separator
3170 .top.file.m add command -label "Exit" -command {exit-action}
3172 menubutton .top.target -text "Target" -menu .top.target.m
3174 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
3175 .top.target.m add command -label "Disconnect" -command {close-target}
3176 .top.target.m add command -label "About" -command {about-target}
3177 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
3178 .top.target.m add command -label "Setup new" -command {define-target-dialog}
3179 .top.target.m add separator
3180 set-target-hotlist 0
3182 configure-disable-e .top.target.m 1
3183 configure-disable-e .top.target.m 2
3185 menu .top.target.m.clist
3186 menu .top.target.m.slist
3189 menubutton .top.service -text "Service" -menu .top.service.m
3191 .top.service.m add command -label "Database" -command {database-select}
3192 .top.service.m add cascade -label "Present" -menu .top.service.m.present
3193 menu .top.service.m.present
3194 .top.service.m.present add command -label "10 More" \
3195 -command [list present-more 10]
3196 .top.service.m.present add command -label "All" \
3197 -command [list present-more {}]
3198 .top.service.m add command -label "Search" -command {search-request 0}
3199 .top.service.m add command -label "Scan" -command {scan-request}
3201 .top.service configure -state disabled
3203 menubutton .top.rset -text "Set" -menu .top.rset.m
3205 .top.rset.m add command -label "Load" -command {load-set}
3206 .top.rset.m add separator
3208 menubutton .top.options -text "Options" -menu .top.options.m
3210 .top.options.m add cascade -label "Query" -menu .top.options.m.query
3211 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
3212 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
3213 .top.options.m add cascade -label "Syntax" -menu .top.options.m.syntax
3214 .top.options.m add cascade -label "Elements" -menu .top.options.m.elements
3216 menu .top.options.m.query
3217 .top.options.m.query add cascade -label "Select" \
3218 -menu .top.options.m.query.clist
3219 .top.options.m.query add cascade -label "Edit" \
3220 -menu .top.options.m.query.slist
3221 .top.options.m.query add command -label "New" \
3222 -command {query-new}
3223 .top.options.m.query add cascade -label "Delete" \
3224 -menu .top.options.m.query.dlist
3226 menu .top.options.m.query.slist
3227 menu .top.options.m.query.clist
3228 menu .top.options.m.query.dlist
3231 menu .top.options.m.formats
3233 foreach f $displayFormats {
3234 .top.options.m.formats add radiobutton -label $f -value $i \
3235 -command [list set-display-format $i] -variable displayFormat
3239 menu .top.options.m.wrap
3240 .top.options.m.wrap add radiobutton -label "Character" \
3241 -value char -variable textWrap -command {set-wrap char}
3242 .top.options.m.wrap add radiobutton -label "Word" \
3243 -value word -variable textWrap -command {set-wrap word}
3244 .top.options.m.wrap add radiobutton -label "None" \
3245 -value none -variable textWrap -command {set-wrap none}
3247 menu .top.options.m.syntax
3248 .top.options.m.syntax add radiobutton -label "None" \
3249 -value None -variable recordSyntax
3250 .top.options.m.syntax add separator
3251 .top.options.m.syntax add radiobutton -label "USMARC" \
3252 -value USMARC -variable recordSyntax
3253 .top.options.m.syntax add radiobutton -label "UNIMARC" \
3254 -value UNIMARC -variable recordSyntax
3255 .top.options.m.syntax add radiobutton -label "UKMARC" \
3256 -value UKMARC -variable recordSyntax
3257 .top.options.m.syntax add radiobutton -label "DANMARC" \
3258 -value DANMARC -variable recordSyntax
3259 .top.options.m.syntax add radiobutton -label "FINMARC" \
3260 -value FINMARC -variable recordSyntax
3261 .top.options.m.syntax add radiobutton -label "NORMARC" \
3262 -value NORMARC -variable recordSyntax
3263 .top.options.m.syntax add radiobutton -label "PICAMARC" \
3264 -value PICAMARC -variable recordSyntax
3265 .top.options.m.syntax add separator
3266 .top.options.m.syntax add radiobutton -label "SUTRS" \
3267 -value SUTRS -variable recordSyntax
3268 .top.options.m.syntax add separator
3269 .top.options.m.syntax add radiobutton -label "GRS1" \
3270 -value GRS1 -variable recordSyntax
3272 menu .top.options.m.elements
3273 .top.options.m.elements add radiobutton -label "Unspecified" \
3274 -value None -variable elementSetNames
3275 .top.options.m.elements add radiobutton -label "Full" \
3276 -value F -variable elementSetNames
3277 .top.options.m.elements add radiobutton -label "Brief" \
3278 -value B -variable elementSetNames
3280 menubutton .top.help -text "Help" -menu .top.help.m
3283 .top.help.m add command -label "Help on help" \
3284 -command {tkerror "Help on help not available. Sorry"}
3285 .top.help.m add command -label "About" -command {about-origin}
3287 pack .top.file .top.target .top.service .top.rset .top.options -side left
3288 pack .top.help -side right
3290 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
3292 button .mid.search -text Search -command {search-request 0} \
3294 button .mid.scan -text Scan \
3295 -command scan-request -state disabled
3296 button .mid.present -text {Present} -command [list present-more 10] \
3299 button .mid.clear -text Clear -command index-clear
3300 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
3303 text .data.record -height 2 -width 20 -wrap none -borderwidth 0 -relief flat \
3304 -yscrollcommand [list .data.scroll set] -wrap $textWrap
3305 scrollbar .data.scroll -command [list .data.record yview]
3307 .data.record configure -takefocus 0
3308 .data.scroll configure -takefocus 0
3310 pack .data.scroll -side right -fill y
3311 pack .data.record -expand yes -fill both
3315 .data.record tag configure marc-tag -foreground blue
3316 .data.record tag configure marc-id -foreground red
3318 .data.record tag configure marc-tag -foreground black
3319 .data.record tag configure marc-id -foreground black
3321 .data.record tag configure marc-data -foreground black
3322 .data.record tag configure marc-head \
3323 -font -Adobe-Times-Bold-R-Normal-*-140-* \
3324 -foreground brown -relief raised -borderwidth 1
3325 .data.record tag configure marc-small-head -foreground brown
3326 .data.record tag configure marc-pref \
3327 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3329 .data.record tag configure marc-text \
3330 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3332 .data.record tag configure marc-it \
3333 -font -Adobe-Times-Medium-I-Normal-*-140-* \
3336 button .bot.logo -bitmap @${libdir}/bitmaps/book1 -command cancel-operation
3338 .bot.logo configure -takefocus 0
3341 pack .bot.a -side left -fill x
3342 pack .bot.logo -side right -padx 2 -pady 2 -ipadx 1
3344 message .bot.a.target -text "" -aspect 1000 -border 1
3346 label .bot.a.status -text "Not connected" -width 15 -relief \
3347 sunken -anchor w -border 1
3348 label .bot.a.set -text "" -width 5 -relief \
3349 sunken -anchor w -border 1
3350 label .bot.a.message -text "" -width 15 -relief \
3351 sunken -anchor w -border 1
3353 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
3354 pack .bot.a.status .bot.a.set .bot.a.message \
3355 -side left -padx 2 -pady 2 -ipadx 1 -ipady 1
3357 if {[catch {ir z39}]} {
3358 set e [info sharedlibextension]
3359 puts -nonewline "Loading irtcl$e ..."
3366 if {$hostid != "Default"} {
3367 catch {open-target $hostid $hostbase}