1 # IR toolkit for tcl/tk
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
7 # Revision 1.76 1995-10-18 15:15:20 adam
10 # Revision 1.75 1995/10/17 14:18:05 adam
11 # Minor changes in presentation formats.
13 # Revision 1.74 1995/10/17 12:18:57 adam
14 # Bug fix: when target connection closed, the connection was not
15 # properly reestablished.
17 # Revision 1.73 1995/10/17 10:58:06 adam
18 # More work on presentation formats.
20 # Revision 1.72 1995/10/16 17:00:52 adam
21 # New setting: elementSetNames.
22 # Various client improvements. Medium presentation format looks better.
24 # Revision 1.71 1995/10/13 15:35:27 adam
25 # Relational operators may be used in search entries - changes
26 # in proc index-query.
28 # Revision 1.70 1995/10/12 14:46:52 adam
29 # Better record popup windows. Next/prev buttons in popup record windows.
30 # The record position in the raw format is much more visible.
32 # Revision 1.69 1995/09/21 13:42:54 adam
35 # Revision 1.68 1995/09/21 13:11:49 adam
36 # Support of dynamic loading.
37 # Test script uses load command if necessary.
39 # Revision 1.67 1995/09/20 14:35:19 adam
42 # Revision 1.66 1995/08/29 15:30:13 adam
43 # Work on GRS records.
45 # Revision 1.65 1995/08/24 15:39:09 adam
48 # Revision 1.64 1995/08/24 15:33:02 adam
51 # Revision 1.63 1995/08/04 13:20:48 adam
52 # Buttons at the bottom are slightly smaller.
54 # Revision 1.62 1995/08/04 11:32:37 adam
55 # More work on output queue. Memory related routines moved
58 # Revision 1.61 1995/07/20 08:09:39 adam
59 # client.tcl: Targets removed from hotTargets list when targets
60 # are removed/modified.
61 # ir-tcl.c: More work on triggerResourceControl.
63 # Revision 1.60 1995/06/30 16:30:19 adam
66 # Revision 1.59 1995/06/29 14:06:25 adam
67 # Another bug in install fixed. Configure searches for more versions of yaz.
69 # Revision 1.58 1995/06/29 12:34:06 adam
70 # IrTcl now works with both tk4.0b4/tcl7.4b4 and tk3.6/tcl7.3
72 # Revision 1.57 1995/06/29 09:20:30 adam
73 # Target entries in cascade menus are sorted.
75 # Revision 1.56 1995/06/27 19:03:48 adam
76 # Bug fix in do_present in ir-tcl.c: p->set_child member weren't set.
77 # nextResultSetPosition used instead of setOffset.
79 # Revision 1.55 1995/06/27 17:10:37 adam
80 # Bug fix: install procedure didn't work on some systems.
81 # Error turned up when clientrc.tcl was't present.
83 # Revision 1.54 1995/06/27 14:41:03 adam
84 # Bug fix in search-response. Didn't always observe non-surrogate diagnostics.
86 # Revision 1.53 1995/06/26 12:40:09 adam
87 # Client defines its own tkerror.
88 # User may specify 'no preferredRecordSyntax'.
90 # Revision 1.52 1995/06/22 13:14:59 adam
91 # Feature: SUTRS. Setting getSutrs implemented.
92 # Work on display formats.
93 # Preferred record syntax can be set by the user.
95 # Revision 1.51 1995/06/21 11:11:00 adam
96 # Bug fix: libdir undefined in about-origin.
98 # Revision 1.50 1995/06/21 11:04:48 adam
99 # Uses GNU autoconf 2.3.
100 # Install procedure implemented.
101 # boook bitmaps moved to sub directory bitmaps.
103 # Revision 1.49 1995/06/20 14:16:42 adam
104 # More work on cancel mechanism.
106 # Revision 1.48 1995/06/20 08:07:23 adam
107 # New setting: failInfo.
108 # Working on better cancel mechanism.
110 # Revision 1.47 1995/06/19 14:05:29 adam
111 # Bug fix: asked for SUTRS.
113 # Revision 1.46 1995/06/19 13:06:06 adam
114 # New define: IR_TCL_VERSION.
116 # Revision 1.45 1995/06/19 08:08:44 adam
117 # client.tcl: hotTargets now contain both database and target name.
118 # ir-tcl.c: setting protocol edited. Errors in callbacks are logged
119 # by logf(LOG_WARN, ...) calls.
121 # Revision 1.44 1995/06/16 14:55:18 adam
122 # Book logo mirrored.
124 # Revision 1.43 1995/06/16 14:41:05 adam
125 # Scan line entries can be copied to a search entry.
127 # Revision 1.42 1995/06/16 12:28:13 adam
128 # Implemented preferredRecordSyntax.
129 # Minor changes in diagnostic handling.
130 # Record list deleted when connection closes.
132 # Revision 1.41 1995/06/14 15:07:59 adam
133 # Bug fix in cascade-target-list. Uses yaz-version.h.
135 # Revision 1.40 1995/06/14 13:37:17 adam
136 # Setting recordType implemented.
137 # Setting implementationVersion implemented.
138 # Settings implementationId / implementationName edited.
140 # Revision 1.39 1995/06/14 12:16:22 adam
141 # hotTargets, textWrap and displayFormat saved in clientg.tcl.
143 # Revision 1.38 1995/06/14 07:22:45 adam
144 # Target definitions can be deleted.
145 # Listbox used in the query definition dialog.
147 # Revision 1.37 1995/06/13 14:37:59 adam
148 # Work on query setup.
149 # Better about origin/target.
150 # Better presentation formats.
152 # Revision 1.36 1995/06/13 07:42:14 adam
153 # Bindings removed from text widgets.
155 # Revision 1.35 1995/06/12 15:17:31 adam
156 # Text widget used in main window (instead of listbox) to support
157 # better presentation formats.
159 # Revision 1.34 1995/06/12 07:59:07 adam
160 # More work on geometry handling.
162 # Revision 1.33 1995/06/09 11:17:35 adam
163 # Start work on geometry management.
165 # Revision 1.32 1995/06/07 09:16:37 adam
166 # New presentation format.
168 # Revision 1.31 1995/06/06 16:31:09 adam
169 # Bug fix: target names couldn't contain blanks.
172 # Revision 1.30 1995/06/06 11:35:41 adam
173 # Work on scan. Display of old sets.
175 # Revision 1.29 1995/06/05 14:11:18 adam
176 # Bug fix in present-more.
178 # Revision 1.28 1995/06/02 14:52:13 adam
179 # Minor changes really.
181 # Revision 1.27 1995/06/02 14:29:42 adam
182 # Work on scan interface - up/down buttons.
184 # Revision 1.26 1995/06/01 16:36:46 adam
185 # About buttons. Minor bug fixes.
187 # Revision 1.25 1995/05/31 13:09:57 adam
188 # Client searches/presents may be interrupted.
189 # New moving book-logo.
191 # Revision 1.24 1995/05/31 08:36:24 adam
192 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
193 # New method: referenceId. More work on scan.
195 # Revision 1.23 1995/05/29 10:33:41 adam
196 # README and rename of startup script.
198 # Revision 1.22 1995/05/26 11:44:09 adam
199 # Bugs fixed. More work on MARC utilities and queries. Test
200 # client is up-to-date again.
202 # Revision 1.21 1995/05/11 15:34:46 adam
203 # Scan request changed a bit. This version works with RLG.
205 # Revision 1.20 1995/04/21 16:31:57 adam
206 # New radiobutton: protocol (z39v2/SR).
208 # Revision 1.19 1995/04/18 16:11:50 adam
209 # First version of graphical Scan. Some work on query-by-form.
211 # Revision 1.18 1995/04/10 10:50:22 adam
212 # Result-set name defaults to suffix of ir-set name.
213 # Started working on scan. Not finished at this point.
215 # Revision 1.17 1995/03/31 09:34:57 adam
216 # Search-button disabled when there is no connection.
218 # Revision 1.16 1995/03/31 08:56:36 adam
219 # New button "Search".
221 # Revision 1.15 1995/03/28 12:45:22 adam
222 # New ir method failback: called on disconnect/protocol error.
223 # New ir set/get method: protocol: SR / Z3950.
224 # Simple popup and disconnect when failback is invoked.
226 # Revision 1.14 1995/03/22 16:07:55 adam
229 # Revision 1.13 1995/03/21 17:27:26 adam
230 # Short-hand keys in setup.
232 # Revision 1.12 1995/03/21 13:41:03 adam
233 # Comstack cs_create not used too often. Non-blocking connect.
235 # Revision 1.11 1995/03/21 10:39:06 adam
236 # Diagnostic error message displayed with tkerror.
238 # Revision 1.10 1995/03/20 15:24:06 adam
239 # Diagnostic records saved on searchResponse.
241 # Revision 1.9 1995/03/17 18:26:16 adam
242 # Non-blocking i/o used now. Database names popup as cascade items.
244 # Revision 1.8 1995/03/17 15:45:00 adam
245 # Improved target/database setup.
247 # Revision 1.7 1995/03/16 17:54:03 adam
248 # Minor changes really.
250 # Revision 1.6 1995/03/15 19:10:20 adam
251 # Database setup in protocol-setup (rather target setup).
253 # Revision 1.5 1995/03/15 13:59:23 adam
256 # Revision 1.4 1995/03/14 17:32:29 adam
257 # Presentation of full Marc record in popup window.
259 # Revision 1.3 1995/03/12 19:31:52 adam
260 # Pattern matching implemented when retrieving MARC records. More
261 # diagnostic functions.
263 # Revision 1.2 1995/03/10 18:00:15 adam
264 # Actual presentation in line-by-line format. RPN query support.
266 # Revision 1.1 1995/03/09 16:15:07 adam
267 # First presentRequest attempts. Hot-target list.
271 if {$tk_version == "3.6"} {
282 proc configure-enable-e {w n} {
284 $w entryconfigure $n -state normal
286 proc configure-disable-e {w n} {
288 $w entryconfigure $n -state disabled
290 set noFocus [list -takefocus 0]
292 proc configure-enable-e {w n} {
295 proc configure-disable-e {w n} {
302 if {[tk colormodel .] == "color"} {
312 if {[file readable bitmaps/book2]} {
315 if {! [file readable ${libdir}/bitmaps/book2]} {
316 puts "Cannot locate system files in ${libdir}. You must either run this"
317 puts "program from the source directory root of ir-tcl or you must assure"
318 puts "that it is installed - normally in /usr/local/lib/irtcl"
326 set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} Z39 1}
328 set settingsChanged 0
336 set recordSyntax None
337 set elementSetNames None
340 set queryTypes {Simple}
341 set queryButtons { { {I 0} {I 1} {I 2} } }
342 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
343 {Subject {1=21}} {Any {1=1016}} } }
352 if {[winfo exists $w]} {
361 label $w.top.b -bitmap error
362 message $w.top.t -aspect 300 -text "Error: $err" \
363 -font -Adobe-Helvetica-Bold-R-Normal-*-180-*
364 pack $w.top.b $w.top.t -side left -padx 10 -pady 10
366 bottom-buttons $w [list {Close} [list destroy $w]] 1
369 proc read-formats {} {
370 global displayFormats
372 if {[catch {set formats [glob -nocomplain ${libdir}/formats/*.tcl]}]} {
373 set formats ./formats/raw.tcl
376 if {[file readable $f]} {
378 set l [string length $f]
379 set f [string range $f [string length "${libdir}/formats/"] \
381 lappend displayFormats $f
390 .data.record configure -wrap $m
397 proc set-display-format {f} {
407 .bot.a.status configure -text "Reformatting"
410 add-title-lines -1 10000 1
413 proc initBindings {} {
416 bind $w <Double-1> {}
417 bind $w <Triple-1> {}
418 bind $w <B1-Motion> {}
420 bind $w <Shift-B1-Motion> {}
422 bind $w <B2-Motion> {}
423 bind $w <Any-KeyPress> {}
425 bind $w <BackSpace> {}
427 bind $w <Control-h> {}
428 bind $w <Control-d> {}
429 bind $w <Control-v> {}
432 bind $w <B1-Motion> {}
433 bind $w <Shift-B1-Motion> {}
438 proc post-menu {wbutton wmenu} {
441 $wmenu post [winfo rootx $wbutton] \
442 [expr [winfo rooty $wbutton]+[winfo height $wbutton]]
447 global windowGeometry
448 set windowGeometry($w) [wm geometry $w]
451 global windowGeometry
454 if {[info exists windowGeometry($w)]} {
455 set g $windowGeometry($w)
460 bind $w <Destroy> [list destroyGW $w]
463 if {[file readable "clientrc.tcl"]} {
464 source "clientrc.tcl"
466 if {[file readable "${libdir}/clientrc.tcl"]} {
467 source "${libdir}/clientrc.tcl"
471 if {[file readable "~/.clientrc.tcl"]} {
472 source "~/.clientrc.tcl"
475 set queryButtonsFind [lindex $queryButtons 0]
476 set queryInfoFind [lindex $queryInfo 0]
478 proc top-down-window {w} {
479 frame $w.top -relief raised -border 1
480 frame $w.bot -relief raised -border 1
482 pack $w.top -side top -fill both -expand yes
483 pack $w.bot -fill both
486 proc top-down-ok-cancel {w ok-action g} {
487 frame $w.bot.left -relief sunken -border 1
488 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 1 -pady 1
489 button $w.bot.left.ok -width 4 -text {Ok} \
490 -command ${ok-action}
491 pack $w.bot.left.ok -expand yes -ipadx 1 -ipady 1 -padx 2 -pady 2
492 button $w.bot.cancel -width 5 -text {Cancel} \
493 -command [list destroy $w]
494 pack $w.bot.cancel -side left -expand yes
502 proc bottom-buttons {w buttonList g} {
504 set l [llength $buttonList]
506 frame $w.bot.$i -relief sunken -border 1
507 pack $w.bot.$i -side left -expand yes -padx 2 -pady 2
508 button $w.bot.$i.ok -text [lindex $buttonList $i] \
509 -command [lindex $buttonList [expr $i+1]]
510 pack $w.bot.$i.ok -expand yes -padx 2 -pady 2 -side left
514 button $w.bot.$i -text [lindex $buttonList $i] \
515 -command [lindex $buttonList [expr $i+1]]
516 pack $w.bot.$i -expand yes -padx 2 -pady 2 -side left
526 proc cancel-operation {} {
534 show-status Cancel 0 1
538 proc show-target {target base} {
542 .bot.a.target configure -text ""
546 .bot.a.target configure -text "$target"
548 .bot.a.target configure -text "$target - $base"
552 proc show-logo {v1} {
561 .bot.logo configure -bitmap @${libdir}/bitmaps/book${v1}
562 after 140 [list show-logo $v1]
566 .bot.logo configure -bitmap @${libdir}/bitmaps/book1
575 proc show-status {status b sb} {
582 .bot.a.status configure -text "$status"
584 if {$busy == 0} {set busy 1}
592 .top.service configure -state normal
593 .mid.search configure -state normal
595 .mid.scan configure -state normal
598 configure-disable-e .top.service.m 1
599 } elseif {[z39.$setNo nextResultSetPosition] > 0 &&
600 [z39.$setNo nextResultSetPosition] <= [z39.$setNo resultCount]} {
601 configure-enable-e .top.service.m 1
602 .mid.present configure -state normal
604 configure-disable-e .top.service.m 1
605 .mid.present configure -state disabled
607 if {[winfo exists .scan-window]} {
608 .scan-window.bot.2 configure -state normal
609 .scan-window.bot.4 configure -state normal
612 .top.service configure -state disabled
613 .mid.search configure -state disabled
614 .mid.scan configure -state disabled
615 .mid.present configure -state disabled
617 if {[winfo exists .scan-window]} {
618 .scan-window.bot.2 configure -state disabled
619 .scan-window.bot.4 configure -state disabled
624 proc show-message {msg} {
625 .bot.a.message configure -text "$msg"
628 proc insertWithTags {w text args} {
629 set start [$w index insert]
630 $w insert insert $text
631 foreach tag [$w tag names $start] {
632 $w tag remove $tag $start insert
635 $w tag add $i $start insert
639 proc popup-license {} {
644 wm title $w "License"
650 text $w.top.t -width 80 -height 10 -wrap word \
651 -yscrollcommand [list $w.top.s set]
652 scrollbar $w.top.s -command [list $w.top.t yview]
654 pack $w.top.s -side right -fill y
655 pack $w.top.t -expand yes -fill both
657 if {[file readable "${libdir}/LICENSE"]} {
658 set f [open "${libdir}/LICENSE" r]
659 while {[gets $f buf] != -1} {
660 $w.top.t insert end $buf
661 $w.top.t insert end "\n"
665 bottom-buttons $w [list {Close} [list destroy $w]] 1
668 proc about-target {} {
669 set w .about-target-w
674 wm title $w "About target"
678 frame $w.top.a -relief ridge -border 2
679 frame $w.top.p -relief ridge -border 2
681 pack $w.top.a $w.top.p -side top -fill x
683 label $w.top.a.about -text "About"
684 label $w.top.a.irtcl -text $hostid \
685 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
686 pack $w.top.a.about $w.top.a.irtcl -side top
688 set i [z39 targetImplementationName]
689 label $w.top.p.in -text "Implementation name: $i"
690 set i [z39 targetImplementationId]
691 label $w.top.p.ii -text "Implementation id: $i"
692 set i [z39 targetImplementationVersion]
693 label $w.top.p.iv -text "Implementation version: $i"
695 label $w.top.p.op -text "Protocol options: $i"
697 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
699 bottom-buttons $w [list {Close} [list destroy $w]] 1
702 proc about-origin-logo {n} {
704 set w .about-origin-w
705 if {![winfo exists $w]} {
712 $w.top.a.logo configure -bitmap @${libdir}/bitmaps/book$n
713 after 140 [list about-origin-logo $n]
716 proc about-origin {} {
717 set w .about-origin-w
721 if {[winfo exists $w]} {
726 wm title $w "About IrTcl"
730 frame $w.top.a -relief ridge -border 2
731 frame $w.top.p -relief ridge -border 2
733 pack $w.top.a $w.top.p -side top -fill x
735 label $w.top.a.irtcl -text "IrTcl" \
736 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
737 label $w.top.a.logo -bitmap @${libdir}/bitmaps/book1
738 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
741 catch {set i [z39 implementationName]}
742 label $w.top.p.in -text "Implementation name: $i"
743 catch {set i [z39 implementationId]}
744 label $w.top.p.ii -text "Implementation id: $i"
745 catch {set i [z39 implementationVersion]}
746 label $w.top.p.iv -text "Implementation version: $i"
748 label $w.top.p.tk -text "Tk version: $i"
750 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.tk -side top -anchor nw
753 bottom-buttons $w [list {Close} [list destroy $w] \
754 {License} [list popup-license]] 0
757 proc popup-marc {sno no b df} {
758 global displayFormats
761 if {[z39.$sno type $no] != "DB"} {
766 while {[winfo exists .full-marc$b]} {
772 if {![winfo exists $w]} {
777 frame $w.top -relief raised -border 1
778 frame $w.bot -relief raised -border 1
780 pack $w.top -side top -fill both -expand yes
781 pack $w.bot -fill both
783 text $w.top.record -width 60 -height 5 -wrap word \
784 -yscrollcommand [list $w.top.s set]
785 scrollbar $w.top.s -command [list $w.top.record yview]
789 $w.top.record tag configure marc-tag -foreground blue
790 $w.top.record tag configure marc-id -foreground red
792 $w.top.record tag configure marc-tag -foreground black
793 $w.top.record tag configure marc-id -foreground black
795 $w.top.record tag configure marc-data -foreground black
796 $w.top.record tag configure marc-head \
797 -font -Adobe-Times-Medium-R-Normal-*-180-* \
798 -background black -foreground white
800 $w.top.record tag configure marc-pref \
801 -font -Adobe-Times-Medium-R-Normal-*-180-* \
803 $w.top.record tag configure marc-text \
804 -font -Adobe-Times-Medium-R-Normal-*-180-* \
806 $w.top.record tag configure marc-it \
807 -font -Adobe-Times-Medium-I-Normal-*-180-* \
810 pack $w.top.s -side right -fill y
811 pack $w.top.record -expand yes -fill both
813 bottom-buttons $w [list \
814 {Close} [list destroy $w] \
818 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m \
820 menu $w.bot.formats.m
821 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 \
822 -padx 3 -pady 3 -side left
824 $w.bot.formats.m delete 0 last
827 foreach f $displayFormats {
828 $w.bot.formats.m add radiobutton -label $f \
829 -variable popupMarcdf -value $i \
830 -command [list popup-marc $sno $no $b 0]
833 $w.top.record delete 0.0 end
834 set recordType [z39.$sno recordType $no]
835 wm title $w "$recordType record #$no"
837 $w.bot.2 configure -command \
838 [list popup-marc $sno [expr $no-1] $b $df]
839 $w.bot.4 configure -command \
840 [list popup-marc $sno [expr $no+1] $b $df]
842 $w.bot.2 configure -state disabled
844 $w.bot.2 configure -state normal
846 if {[z39.$sno type [expr $no+1]] != "DB"} {
847 $w.bot.4 configure -state disabled
849 $w.bot.4 configure -state normal
851 $w.bot.6 configure -command [list popup-marc $sno $no -1 0]
852 set ffunc [lindex $displayFormats $df]
853 set ffunc "display-$ffunc"
855 $ffunc $sno $no $w.top.record 0
858 proc update-target-hotlist {target base} {
861 set olen [llength $hotTargets]
863 foreach e $hotTargets {
864 if {$target == [lindex $e 0] && $base == [lindex $e 1]} {
865 set hotTargets [lreplace $hotTargets $i $i]
870 set hotTargets [linsert $hotTargets 0 [list $target $base]]
871 set-target-hotlist $olen
874 proc delete-target-hotlist {target} {
877 set olen [llength $hotTargets]
879 foreach e $hotTargets {
880 if {$target == [lindex $e 0]} {
881 set hotTargets [lreplace $hotTargets $i $i]
885 set-target-hotlist $olen
888 proc set-target-hotlist {olen} {
893 .top.target.m delete 7 [expr 7+$olen]
895 .top.target.m delete 6 [expr 6+$olen]
899 foreach e $hotTargets {
900 set target [lindex $e 0]
901 set base [lindex $e 1]
903 .top.target.m add command -label "$i $target" -command \
904 [list reopen-target $target {}]
906 .top.target.m add command -label "$i $target - $base" -command \
907 [list reopen-target $target $base]
916 proc reopen-target {target base} {
918 open-target $target $base
919 update-target-hotlist $target $base
922 proc define-target-action {} {
925 set target [.target-define.top.target.entry get]
929 foreach n [array names profile] {
935 set seq [lindex $profile(Default) 12]
937 set profile($target) $profile(Default)
938 set profile(Default) [lreplace $profile(Default) 12 12 [incr seq]]
940 protocol-setup $target
941 destroy .target-define
944 proc fail-response {target} {
945 set c [lindex [z39 failInfo] 0]
946 set m [lindex [z39 failInfo] 1]
951 proc connect-response {target base} {
952 dputs "connect-response"
953 show-target $target $base
957 proc open-target {target base} {
962 z39 comstack [lindex $profile($target) 6]
963 z39 protocol [lindex $profile($target) 11]
964 z39 idAuthentication [lindex $profile($target) 3]
965 z39 maximumRecordSize [lindex $profile($target) 4]
966 z39 preferredMessageSize [lindex $profile($target) 5]
967 dputs "maximumRecordSize="
968 dputs [z39 maximumRecordSize]
969 dputs "preferredMessageSize="
970 dputs [z39 preferredMessageSize]
971 show-status Connecting 1 0
973 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
975 z39 databaseNames $base
977 z39 failback [list fail-response $target]
978 z39 callback [list connect-response $target $base]
981 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
984 tkerror $errorMessage
985 show-status "Not connected" 0 {}
989 configure-disable-e .top.target.m 0
990 configure-enable-e .top.target.m 1
991 configure-enable-e .top.target.m 2
994 proc close-target {} {
1003 .bot.a.set configure -text ""
1007 show-status {Not connected} 0 0
1010 configure-disable-e .top.target.m 1
1011 configure-disable-e .top.target.m 2
1013 .top.rset.m delete 2 last
1015 .top.rset.m delete 1 last
1017 .top.rset.m add separator
1018 configure-enable-e .top.target.m 0
1021 proc load-set-action {} {
1025 ir-set z39.$setNoLast z39
1027 set fname [.load-set.top.filename.entry get]
1030 show-status Loading 1 {}
1032 z39.$setNoLast loadFile $fname
1034 set no [z39.$setNoLast numberOfRecordsReturned]
1035 add-title-lines $setNoLast $no 1
1037 set l [format "%-4d %7d" $setNoLast $no]
1038 .top.rset.m add command -label $l \
1039 -command [list add-title-lines $setNoLast 10000 1]
1040 show-status Ready 0 {}
1046 set oldFocus [focus]
1050 frame $w.top.filename
1051 pack $w.top.filename -side top -anchor e -pady 2
1053 entry-fields $w.top {filename} \
1055 {load-set-action} {destroy .load-set}
1057 top-down-ok-cancel $w {load-set-action} 1
1061 proc init-request {} {
1068 z39 callback {init-response}
1069 show-status Initializing 1 {}
1070 set err [catch {z39 init} errorMessage]
1072 tkerror $errorMessage
1073 show-status Ready 0 {}
1077 proc init-response {} {
1081 dputs {init-reponse}
1086 if {![z39 initResult]} {
1087 show-status Ready 0 1
1088 set u [z39 userInformationField]
1090 tkerror "Connection rejected by target: $u"
1092 if {[lsearch [z39 options] scan] >= 0} {
1097 show-status Ready 0 1
1101 proc search-request {bflag} {
1110 global elementSetNames
1114 if {[z39 connect] == ""} {
1117 dputs "search-request"
1119 if {!$bflag && $busy} {
1120 dputs "busy: search-request ignored"
1125 show-status Searching 1 0
1126 set delayRequest {search-request 1}
1131 set query [index-query]
1136 set setNo $setNoLast
1137 ir-set z39.$setNo z39
1139 if {[lindex $profile($target) 10] == 1} {
1140 z39.$setNo setName $setNo
1141 dputs "setName=${setNo}"
1143 z39.$setNo setName Default
1144 dputs "setName=Default"
1146 if {[lindex $profile($target) 8] == 1} {
1147 z39.$setNo queryType rpn
1149 if {[lindex $profile($target) 9] == 1} {
1150 z39.$setNo queryType ccl
1154 if {$recordSyntax == "None" } {
1155 z39.$setNo preferredRecordSyntax {}
1157 z39.$setNo preferredRecordSyntax $recordSyntax
1159 if {$elementSetNames == "None" } {
1160 z39.$setNo elementSetNames {}
1162 z39.$setNo elementSetNames $elementSetNames
1164 z39 callback {search-response}
1165 z39.$setNo search $query
1166 show-status Searching 1 0
1169 proc scan-copy {y entry} {
1171 set no [$w.top.list nearest $y]
1173 .lines.$entry.e delete 0 end
1174 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
1177 proc scan-request {} {
1184 global curIndexEntry
1185 global queryButtonsFind
1186 global queryInfoFind
1190 dputs "scan-request"
1193 show-status Scanning 1 0
1194 set delayRequest scan-request
1203 set b [lindex $queryButtonsFind $curIndexEntry]
1205 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
1206 set attr "@attr $a $attr"
1208 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
1209 ir-scan z39.scan z39
1211 if {![winfo exists $w]} {
1218 entry $w.top.entry -relief sunken
1219 pack $w.top.entry -fill x -padx 4 -pady 2
1220 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
1221 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
1223 scrollbar $w.top.scroll -orient vertical -border 1
1224 pack $w.top.list -side left -fill both -expand yes
1225 pack $w.top.scroll -side right -fill y
1226 $w.top.scroll config -command [list $w.top.list yview]
1228 bottom-buttons $w [list {Close} [list destroy $w] \
1229 {Up} [list scan-up $attr] \
1230 {Down} [list scan-down $attr]] 0
1231 bind $w.top.list <Up> [list scan-up $attr]
1232 bind $w.top.list <Down> [list scan-down $attr]
1235 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
1236 wm title $w "Scan $title"
1238 z39 callback [list scan-response $attr 0 35]
1239 z39.scan numberOfTermsRequested 5
1240 z39.scan preferredPositionInResponse 1
1241 z39.scan scan "${attr} 0"
1243 show-status Scanning 1 0
1246 proc scan-term-h {attr} {
1254 set nScanTerm [$w.top.entry get]
1255 if {$nScanTerm == $scanTerm} {
1258 set scanTerm $nScanTerm
1259 z39 callback [list scan-response $attr 0 35]
1260 z39.scan numberOfTermsRequested 5
1261 z39.scan preferredPositionInResponse 1
1262 dputs "${attr} \{${scanTerm}\}"
1263 if {$scanTerm == ""} {
1264 z39.scan scan "${attr} 0"
1266 z39.scan scan "${attr} \{${scanTerm}\}"
1268 show-status Scanning 1 0
1271 proc scan-response {attr start toget} {
1278 dputs "In scan-response"
1279 set m [z39.scan numberOfEntriesReturned]
1285 if {![winfo exists .scan-window]} {
1288 dputs "Handling cancel"
1289 if {$delayRequest != ""} {
1294 show-status Ready 0 1
1297 set nScanTerm [$w.top.entry get]
1298 if {$nScanTerm != $scanTerm} {
1299 z39 callback [list scan-response $attr 0 35]
1300 z39.scan numberOfTermsRequested 5
1301 z39.scan preferredPositionInResponse 1
1302 set scanTerm $nScanTerm
1303 dputs "${attr} \{${scanTerm}\}"
1304 if {$scanTerm == ""} {
1305 z39.scan scan "${attr} 0"
1307 z39.scan scan "${attr} \{${scanTerm}\}"
1309 show-status Scanning 1 0
1312 set status [z39.scan scanStatus]
1315 show-status Ready 0 1
1320 for {set i 0} {$i < $m} {incr i} {
1321 set term [lindex [z39.scan scanLine $i] 1]
1322 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1323 $w.top.list insert $i "$nostr $term"
1326 $w.top.list yview $scanView
1328 $w.top.list delete $start end
1329 for {set i 0} {$i < $m} {incr i} {
1330 set term [lindex [z39.scan scanLine $i] 1]
1331 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1332 $w.top.list insert end "$nostr $term"
1336 dputs "Handling cancel"
1338 if {$delayRequest != ""} {
1344 if {$toget > 0 && $m > 1 && $m < $toget} {
1345 set ntoget [expr $toget - $m + 1]
1346 dputs ntoget=$ntoget
1347 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1349 dputs "down continue: $q"
1351 z39.scan numberOfTermsRequested 10
1353 z39.scan numberOfTermsRequested $ntoget
1355 z39.scan preferredPositionInResponse 1
1356 dputs "${attr} \{$q\}"
1357 z39.scan scan "${attr} \{$q\}"
1360 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1361 set ntoget [expr - $toget - $m]
1362 dputs ntoget=$ntoget
1363 z39 callback [list scan-response $attr 0 -$ntoget]
1364 set q [string range [$w.top.list get 0] 8 end]
1365 dputs "up continue: $q"
1367 z39.scan numberOfTermsRequested 10
1368 z39.scan preferredPositionInResponse 11
1370 z39.scan numberOfTermsRequested $ntoget
1371 z39.scan preferredPositionInResponse [incr ntoget]
1373 dputs "${attr} \{$q\}"
1374 z39.scan scan "${attr} \{$q\}"
1377 show-status Ready 0 1
1380 proc scan-down {attr} {
1388 show-status {Scanning down} 1 0
1389 set delayRequest [list scan-down $attr]
1395 set scanView [expr $scanView + 5]
1396 set s [$w.top.list size]
1397 if {$scanView > $s} {
1398 z39 callback [list scan-response $attr [expr $s - 1] 25]
1399 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1401 z39.scan numberOfTermsRequested 10
1402 z39.scan preferredPositionInResponse 1
1403 show-status Scanning 1 0
1404 dputs "${attr} \{$q\}"
1405 z39.scan scan "${attr} \{$q\}"
1408 $w.top.list yview $scanView
1411 proc scan-up {attr} {
1419 show-status Scanning 1 0
1420 set delayRequest [list scan-up $attr]
1426 set scanView [expr $scanView - 5]
1427 if {$scanView < 0} {
1428 z39 callback [list scan-response $attr 0 -25]
1429 set q [string range [$w.top.list get 0] 8 end]
1431 z39.scan numberOfTermsRequested 10
1432 z39.scan preferredPositionInResponse 11
1433 show-status Scanning 1 0
1434 z39.scan scan "${attr} \{$q\}"
1437 $w.top.list yview $scanView
1440 proc search-response {} {
1448 dputs "In search-response"
1450 dputs "Handling cancel"
1452 if {$delayRequest != ""} {
1460 set setMax [z39.$setNo resultCount]
1461 show-status Ready 0 1
1462 set status [z39.$setNo responseStatus]
1463 if {[lindex $status 0] == "NSD"} {
1464 z39.$setNo nextResultSetPosition 0
1465 set code [lindex $status 1]
1466 set msg [lindex $status 2]
1467 set addinfo [lindex $status 3]
1468 tkerror "NSD$code: $msg: $addinfo"
1471 show-message "${setMax} hits"
1476 show-status Ready 0 1
1477 set l [format "%-4d %7d" $setNo $setMax]
1478 .top.rset.m add command -label $l \
1479 -command [list add-title-lines $setNo 10000 1]
1483 z39 callback {present-response}
1484 z39.$setNo present $setOffset 1
1485 show-status Retrieving 1 0
1488 proc present-more {number} {
1496 dputs "present-more"
1498 show-status Retrieving 1 0
1499 set delayRequest "present-more $number"
1505 dputs "setNo=$setNo"
1508 set setOffset [z39.$setNo nextResultSetPosition]
1509 dputs "setOffest=${setOffset}"
1510 dputs "setNo=${setNo}"
1511 set max [z39.$setNo resultCount]
1512 if {$max < $setOffset} {
1514 dputs "setOffset=$setOffset"
1515 show-status Ready 0 1
1518 if {$number == ""} {
1522 if {$setMax > $max} {
1526 z39 callback {present-response}
1528 set toGet [expr $setMax - $setOffset + 1]
1535 z39.$setNo present $setOffset $toGet
1536 show-status Retrieving 1 0
1539 proc init-title-lines {} {
1540 .data.record delete 0.0 end
1543 proc add-title-lines {setno no offset} {
1544 global displayFormats
1545 global displayFormat
1555 .bot.a.set configure -text $setno
1556 .data.record delete 0.0 end
1558 set ffunc [lindex $displayFormats $displayFormat]
1559 dputs "ffunc=$ffunc"
1560 set ffunc "display-$ffunc"
1561 for {set i 0} {$i < $no} {incr i} {
1562 set o [expr $i + $offset]
1563 set type [z39.$setno type $o]
1567 .data.record tag bind r$o <Any-Enter> {}
1568 .data.record tag bind r$o <Any-Leave> {}
1569 set insert0 [.data.record index insert]
1570 $ffunc $setno $o .data.record 1
1571 .data.record tag add r$o $insert0 insert
1572 .data.record tag bind r$o <1> \
1573 [list popup-marc $setno $o 0 0]
1577 show-status Ready 0 1
1581 proc present-response {} {
1588 dputs "In present-response"
1589 set no [z39.$setNo numberOfRecordsReturned]
1590 dputs "Returned $no records, setOffset $setOffset"
1591 add-title-lines $setNo $no $setOffset
1592 set setOffset [expr $setOffset + $no]
1594 dputs "Handling cancel"
1596 if {$delayRequest != ""} {
1601 set status [z39.$setNo responseStatus]
1602 if {[lindex $status 0] == "NSD"} {
1603 show-status Ready 0 1
1604 set code [lindex $status 1]
1605 set msg [lindex $status 2]
1606 set addinfo [lindex $status 3]
1607 tkerror "NSD$code: $msg: $addinfo"
1610 if {$no > 0 && $setOffset <= $setMax} {
1611 dputs "present-request from ${setOffset}"
1612 set toGet [expr $setMax - $setOffset + 1]
1616 z39.$setNo present $setOffset $toGet
1618 show-status Ready 0 1
1622 proc left-cursor {w} {
1623 set i [$w index insert]
1631 proc right-cursor {w} {
1632 set i [$w index insert]
1638 proc bind-fields {list returnAction escapeAction} {
1639 set max [expr [llength $list]-1]
1640 for {set i 0} {$i < $max} {incr i} {
1641 bind [lindex $list $i] <Return> $returnAction
1642 bind [lindex $list $i] <Escape> $escapeAction
1644 bind [lindex $list $i] <Tab> \
1645 [list focus [lindex $list [expr $i+1]]]
1646 bind [lindex $list $i] <Left> \
1647 [list left-cursor [lindex $list $i]]
1648 bind [lindex $list $i] <Right> \
1649 [list right-cursor [lindex $list $i]]
1652 bind [lindex $list $i] <Return> $returnAction
1653 bind [lindex $list $i] <Escape> $escapeAction
1655 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1656 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1657 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1659 focus [lindex $list 0]
1662 proc entry-fields {parent list tlist returnAction escapeAction} {
1665 foreach field $list {
1666 set label ${parent}.${field}.label
1667 set entry ${parent}.${field}.entry
1668 label $label -text [lindex $tlist $i] -anchor e
1669 entry $entry -width 32 -relief sunken
1670 pack $label -side left
1671 pack $entry -side right
1672 lappend alist $entry
1675 bind-fields $alist $returnAction $escapeAction
1678 proc define-target-dialog {} {
1679 set w .target-define
1685 pack $w.top.target \
1686 -side top -anchor e -pady 2
1687 entry-fields $w.top {target} \
1689 {define-target-action} {destroy .target-define}
1690 top-down-ok-cancel $w {define-target-action} 1
1693 proc protocol-setup-delete {target w} {
1695 global settingsChanged
1697 set a [alert "Are you sure you want to delete the target \
1698 definition $target ?"]
1701 unset profile($target)
1702 set settingsChanged 1
1704 delete-target-hotlist $target
1708 proc protocol-setup-action {target w} {
1711 global protocolRadioType
1712 global settingsChanged
1715 global ResultSetCheck
1718 set settingsChanged 1
1719 set len [$w.top.databases.list size]
1720 for {set i 0} {$i < $len} {incr i} {
1721 lappend b [$w.top.databases.list get $i]
1723 set wno [lindex $profile($target) 12]
1725 set profile($target) [list [$w.top.description.entry get] \
1726 [$w.top.host.entry get] \
1727 [$w.top.port.entry get] \
1728 [$w.top.idAuthentication.entry get] \
1729 [$w.top.maximumRecordSize.entry get] \
1730 [$w.top.preferredMessageSize.entry get] \
1736 $protocolRadioType \
1740 delete-target-hotlist $target
1741 dputs $profile($target)
1745 proc place-force {window parent} {
1746 set g [wm geometry $parent]
1748 set p1 [string first + $g]
1749 set p2 [string last + $g]
1751 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1752 set y [expr 60+[string range $g [expr $p2 +1] end]]
1753 wm geometry $window +${x}+${y}
1756 proc add-database-action {target w} {
1759 $w.top.databases.list insert end \
1760 [.database-select.top.database.entry get]
1761 destroy .database-select
1764 proc add-database {target wp} {
1767 set w .database-select
1769 set oldFocus [focus]
1775 frame $w.top.database
1777 pack $w.top.database -side top -anchor e -pady 2
1779 entry-fields $w.top {database} \
1780 {{Database to add:}} \
1781 [list add-database-action $target $wp] {destroy .database-select}
1783 top-down-ok-cancel $w [list add-database-action $target $wp] 1
1787 proc delete-database {target w} {
1791 foreach i [$w.top.databases.list curselection] {
1792 set b [$w.top.databases.list get $i]
1795 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1797 foreach i [lsort -decreasing \
1798 [$w.top.databases.list curselection]] {
1799 $w.top.databases.list delete $i
1804 proc protocol-setup {target} {
1807 global protocolRadioType
1810 global ResultSetCheck
1813 while {[winfo exists .setup-$b]} {
1820 wm title $w "Setup $target"
1824 if {$target == ""} {
1828 dputs $profile($target)
1830 frame $w.top.description
1833 frame $w.top.idAuthentication
1834 frame $w.top.maximumRecordSize
1835 frame $w.top.preferredMessageSize
1836 frame $w.top.cs-type -relief ridge -border 2
1837 frame $w.top.protocol -relief ridge -border 2
1838 frame $w.top.query -relief ridge -border 2
1839 frame $w.top.databases -relief ridge -border 2
1841 # Maximum/preferred/idAuth ...
1842 pack $w.top.description $w.top.host $w.top.port \
1843 $w.top.idAuthentication $w.top.maximumRecordSize \
1844 $w.top.preferredMessageSize -side top -anchor e -pady 2
1846 entry-fields $w.top {description host port idAuthentication \
1847 maximumRecordSize preferredMessageSize} \
1848 {{Description:} {Host:} {Port:} {Id Authentication:} \
1849 {Maximum Record Size:} {Preferred Message Size:}} \
1850 [list protocol-setup-action $target $w] [list destroy $w]
1852 foreach sub {description host port idAuthentication \
1853 maximumRecordSize preferredMessageSize} {
1855 bind $w.top.$sub.entry <Control-a> [list add-database $target $w]
1856 bind $w.top.$sub.entry <Control-d> [list delete-database $target $w]
1858 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1859 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1860 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1861 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1862 $w.top.maximumRecordSize.entry insert 0 [lindex $profile($target) 4]
1863 $w.top.preferredMessageSize.entry insert 0 [lindex $profile($target) 5]
1864 set csRadioType [lindex $profile($target) 6]
1865 set RPNCheck [lindex $profile($target) 8]
1866 set CCLCheck [lindex $profile($target) 9]
1867 set ResultSetCheck [lindex $profile($target) 10]
1868 set protocolRadioType [lindex $profile($target) 11]
1869 if {$protocolRadioType == ""} {
1870 set protocolRadioType Z39
1874 pack $w.top.databases -side left -pady 2 -padx 2 -expand yes -fill both
1876 label $w.top.databases.label -text "Databases"
1877 button $w.top.databases.add -text Add \
1878 -command [list add-database $target $w]
1879 button $w.top.databases.delete -text Delete \
1880 -command [list delete-database $target $w]
1882 listbox $w.top.databases.list -geometry 14x6 \
1883 -yscrollcommand "$w.top.databases.scroll set"
1885 listbox $w.top.databases.list -width 14 -height 5\
1886 -yscrollcommand "$w.top.databases.scroll set"
1888 scrollbar $w.top.databases.scroll -orient vertical -border 1
1889 pack $w.top.databases.label -side top -fill x \
1891 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1893 pack $w.top.databases.list -side left -fill both -expand yes \
1895 pack $w.top.databases.scroll -side right -fill y \
1897 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1899 foreach b [lindex $profile($target) 7] {
1900 $w.top.databases.list insert end $b
1904 pack $w.top.cs-type -pady 2 -padx 2 -side top -fill x
1906 label $w.top.cs-type.label -text "Transport"
1907 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1908 -variable csRadioType -value tcpip
1909 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1910 -variable csRadioType -value mosi
1912 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1913 -padx 2 -side top -fill x
1916 pack $w.top.protocol -pady 2 -padx 2 -side top -fill x
1918 label $w.top.protocol.label -text "Protocol"
1919 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1920 -variable protocolRadioType -value Z39
1921 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1922 -variable protocolRadioType -value SR
1924 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1925 -padx 2 -side top -fill x
1928 pack $w.top.query -pady 2 -padx 2 -side top -fill x
1930 label $w.top.query.label -text "Query support"
1931 checkbutton $w.top.query.c1 -text "RPN query" -anchor w -variable RPNCheck
1932 checkbutton $w.top.query.c2 -text "CCL query" -anchor w -variable CCLCheck
1933 checkbutton $w.top.query.c3 -text "Result sets" -anchor w -variable ResultSetCheck
1935 pack $w.top.query.label -side top
1936 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
1937 -padx 2 -side top -fill x
1940 bottom-buttons $w [list {Ok} [list protocol-setup-action $target $w] \
1941 {Delete} [list protocol-setup-delete $target $w] \
1942 {Cancel} [list destroy $w]] 0
1945 proc database-select-action {} {
1946 set w .database-select.top
1948 foreach indx [$w.databases.list curselection] {
1949 lappend b [$w.databases.list get $indx]
1952 z39 databaseNames $b
1954 destroy .database-select
1957 proc database-select {} {
1958 set w .database-select
1963 set oldFocus [focus]
1968 frame $w.top.databases -relief ridge -border 2
1970 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
1972 label $w.top.databases.label -text "List"
1973 listbox $w.top.databases.list -width 20 -height 6 \
1974 -yscrollcommand "$w.top.databases.scroll set"
1975 scrollbar $w.top.databases.scroll -orient vertical -border 1
1976 pack $w.top.databases.label -side top -fill x \
1978 pack $w.top.databases.list -side left -fill both -expand yes \
1980 pack $w.top.databases.scroll -side right -fill y \
1982 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1984 foreach b [lindex $profile($hostid) 7] {
1985 $w.top.databases.list insert end $b
1987 top-down-ok-cancel $w {database-select-action} 1
1991 proc cascade-target-list {} {
1994 foreach sub [winfo children .top.target.m.clist] {
1997 .top.target.m.clist delete 0 last
1998 foreach n [lsort [array names profile]] {
1999 if {$n != "Default"} {
2000 set nl [lindex $profile($n) 12]
2001 if {[llength [lindex $profile($n) 7]] > 1} {
2002 .top.target.m.clist add cascade -label $n \
2003 -menu .top.target.m.clist.$nl
2004 menu .top.target.m.clist.$nl
2005 foreach b [lindex $profile($n) 7] {
2006 .top.target.m.clist.$nl add command -label $b \
2007 -command [list reopen-target $n $b]
2010 .top.target.m.clist add command -label $n \
2011 -command [list reopen-target $n {}]
2015 .top.target.m.slist delete 0 last
2016 foreach n [lsort [array names profile]] {
2017 if {$n != "Default"} {
2018 .top.target.m.slist add command -label $n \
2019 -command [list protocol-setup $n]
2024 proc query-select {i} {
2025 global queryButtonsFind
2026 global queryInfoFind
2030 set queryInfoFind [lindex $queryInfo $i]
2031 set queryButtonsFind [lindex $queryButtons $i]
2033 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2036 proc query-new-action {} {
2040 global settingsChanged
2042 set settingsChanged 1
2043 lappend queryTypes [.query-new.top.index.entry get]
2044 lappend queryButtons {}
2045 lappend queryInfo {}
2055 set oldFocus [focus]
2060 -side top -anchor e -pady 2
2061 entry-fields $w.top index \
2063 query-new-action {destroy .query-new}
2064 top-down-ok-cancel $w query-new-action 1
2068 proc query-delete-action {queryNo} {
2072 global settingsChanged
2074 set settingsChanged 1
2076 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
2077 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
2078 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
2079 destroy .query-delete
2083 proc query-delete {queryNo} {
2091 set n [lindex $queryTypes $queryNo]
2093 label $w.top.warning -bitmap warning
2094 message $w.top.quest -text "Are you sure you want to delete the \
2095 query type $n ?" -aspect 300
2096 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
2097 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
2098 {Cancel} [list destroy $w]] 1
2101 proc cascade-query-list {} {
2103 set w .top.options.m.query
2106 $w.slist delete 0 last
2107 foreach n $queryTypes {
2108 $w.slist add command -label $n -command [list query-setup $i]
2113 $w.clist delete 0 last
2114 foreach n $queryTypes {
2115 $w.clist add command -label $n -command [list query-select $i]
2119 $w.dlist delete 0 last
2120 foreach n $queryTypes {
2121 $w.dlist add command -label $n -command [list query-delete $i]
2126 proc save-geometry {} {
2127 global windowGeometry
2130 global displayFormat
2133 global elementSetNames
2135 set windowGeometry(.) [wm geometry .]
2137 if {[catch {set f [open ~/.clientrc.tcl w]}]} {
2140 puts $f "set hotTargets \{ $hotTargets \}"
2141 puts $f "set textWrap $textWrap"
2142 puts $f "set displayFormat $displayFormat"
2143 puts $f "set popupMarcdf $popupMarcdf"
2144 puts $f "set recordSyntax $recordSyntax"
2145 puts $f "set elementSetNames $elementSetNames"
2146 foreach n [array names windowGeometry] {
2147 puts -nonewline $f "set \{windowGeometry($n)\} \{"
2148 puts -nonewline $f $windowGeometry($n)
2154 proc save-settings {} {
2157 global settingsChanged
2162 if {![file writable "${libdir}/clientrc.tcl"]} {
2163 set a [alert "Cannot open ${libdir}/clientrc.tcl for writing. Do you \
2164 wish to save clientrc.tcl in the current directory instead?"]
2168 set f [open "clientrc.tcl" w]
2170 set f [open "${libdir}/clientrc.tcl" w]
2172 puts $f "# Setup file"
2174 foreach n [array names profile] {
2175 puts -nonewline $f "set \{profile($n)\} \{"
2176 puts -nonewline $f $profile($n)
2179 puts -nonewline $f "set queryTypes \{"
2180 puts -nonewline $f $queryTypes
2183 puts -nonewline $f "set queryButtons \{"
2184 puts -nonewline $f $queryButtons
2187 puts -nonewline $f "set queryInfo \{"
2188 puts -nonewline $f $queryInfo
2191 set settingsChanged 0
2200 set oldFocus [focus]
2204 label $w.top.warning -bitmap warning
2205 message $w.top.message -text $ask -aspect 300 \
2206 -font -Adobe-Times-Medium-R-Normal-*-180-*
2208 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
2211 top-down-ok-cancel $w {alert-action} 1
2216 proc alert-action {} {
2222 proc exit-action {} {
2223 global settingsChanged
2225 if {$settingsChanged} {
2226 set a [alert "you haven't saved your settings. Do you wish to save?"]
2235 proc listbuttonaction {w name h user i} {
2236 $w configure -text [lindex $name 0]
2237 $h [lindex $name 1] $user $i
2240 proc listbuttonx {button no names handle user} {
2241 if {[winfo exists $button]} {
2242 $button configure -text [lindex [lindex $names $no] 0]
2243 ${button}.m delete 0 last
2245 menubutton $button -text [lindex [lindex $names $no] 0] \
2246 -width 10 -menu ${button}.m -relief raised -border 1
2250 foreach name $names {
2251 ${button}.m add command -label [lindex $name 0] \
2252 -command [list listbuttonaction ${button} $name \
2258 proc listbutton {button no names} {
2259 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
2260 -relief raised -border 1
2262 foreach name $names {
2263 ${button}.m add command -label $name \
2264 -command [list ${button} configure -text $name]
2268 proc listbuttonv-action {button var names i} {
2271 set $var [lindex $names [expr $i+1]]
2272 $button configure -text [lindex $names $i]
2275 proc listbuttonv {button var names} {
2279 eval "set val $$var"
2280 set l [llength $names]
2281 for {set i 1} {$i < $l} {incr i 2} {
2282 if {$val == [lindex $names $i]} {
2284 set n [lindex $names $i]
2288 if {[winfo exists $button]} {
2289 $button configure -text $n
2292 menubutton $button -text $n -menu ${button}.m \
2293 -relief raised -border 1
2295 for {set i 0} {$i < $l} {incr i 2} {
2296 ${button}.m add command -label [lindex $names $i] \
2297 -command [list listbuttonv-action $button $var $names $i]
2301 proc query-add-index-action {queryNo} {
2305 global queryButtonsTmp
2307 set newI [.query-add-index.top.index.entry get]
2308 lappend queryInfoTmp [list $newI {}]
2309 $w.top.index.list insert end $newI
2310 destroy .query-add-index
2311 #destroy $w.top.lines
2312 #frame $w.top.lines -relief ridge -border 2
2313 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2314 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2317 proc query-add-line {queryNo} {
2321 global queryButtonsTmp
2323 lappend queryButtonsTmp {I 0}
2325 #destroy $w.top.lines
2326 #frame $w.top.lines -relief ridge -border 2
2327 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2328 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2331 proc query-del-line {queryNo} {
2335 global queryButtonsTmp
2337 set l [llength $queryButtonsTmp]
2342 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
2343 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2346 proc query-add-index {queryNo} {
2347 set w .query-add-index
2350 set oldFocus [focus]
2351 place-force $w .query-setup
2355 -side top -anchor e -pady 2
2356 entry-fields $w.top {index} \
2358 [list query-add-index-action $queryNo] [list destroy $w]
2359 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
2363 proc query-setup-action {queryNo} {
2366 global queryButtonsTmp
2368 global queryButtonsFind
2369 global queryInfoFind
2371 global settingsChanged
2373 set settingsChanged 1
2375 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
2377 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
2379 set queryInfoFind $queryInfoTmp
2380 set queryButtonsFind $queryButtonsTmp
2382 destroy .query-setup
2383 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2386 proc activate-e-index {value no i} {
2387 global queryButtonsTmp
2388 global queryIndexTmp
2390 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
2391 dputs $queryButtonsTmp
2392 set queryIndexTmp $i
2395 proc activate-index {value no i} {
2396 global queryButtonsFind
2398 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
2400 dputs "queryButtonsFind $queryButtonsFind"
2403 proc update-attr {} {
2405 listbuttonv $w.top.relation.b relationTmpValue\
2406 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
2407 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
2408 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
2409 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
2410 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
2411 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
2412 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
2413 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
2414 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
2415 {local-number} 107 {string} 108 {numeric string} 109}
2416 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2417 {Left} 2 {Left and right} 3 {No truncation} 100 \
2418 {Process #} 101 {Re-1} 102 {Re-2} 103}
2419 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2420 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2423 proc use-attr {init} {
2435 {BNB card number} 10
2436 {BGF(sic) number} 11
2438 {Dewey classification} 13
2439 {UDC classification} 14
2440 {Bliss classification} 15
2442 {NLM call number} 17
2443 {NAL call number} 18
2444 {MOS call number} 19
2445 {Local classification} 20
2446 {Subject heading} 21
2448 {BDI-index-subject} 23
2452 {LC-subject-heading} 27
2453 {RVM-subject-heading} 28
2454 {Local subject index} 29
2456 {Date of publication} 31
2457 {Date of acquisition} 32
2459 {Title-collective} 34
2462 {Title-added-title-page} 37
2466 {Title-other-variant} 41
2468 {Title-abbreviated} 43
2472 {Subject-subdivision} 47
2473 {Number-natl-bibliography} 48
2474 {Number-legal-deposit} 49
2475 {Number-govt-publication} 50
2476 {Number-publisher-for-music} 51
2478 {Number-local-call} 53
2480 {Code-geographic-area} 55
2481 {Code-institution} 56
2483 {Name-geographic} 58
2484 {Place-publication} 59
2486 {Microform-generation} 61
2493 {Author-name-personal} 1004
2494 {Author-name-corporate} 1005
2495 {Author-name-conference} 1006
2496 {Identifier-standard} 1007
2497 {Subject-LC-children's} 1008
2498 {Subject-name-personal} 1009
2500 {Date/time added to database} 1011
2501 {Date/time last modified} 1012
2502 {Authority/format identifier} 1013
2504 {Concept-reference} 1015
2506 {Server choice} 1017
2508 {Record source} 1019
2511 {Geographic class} 1022
2515 {Related periodical} 1026
2516 {Report number} 1027
2518 {Thematic number} 1030
2519 {Material type} 1031
2527 set l [llength $attr]
2532 for {set i 0} {$i < $l} {incr i} {
2533 $w.top.use.list insert end [lindex $attr $i]
2535 if {$useTmpValue == [lindex $attr $i]} {
2541 $w.top.use.list selection clear 0 end
2542 $w.top.use.list selection set $s $s
2544 $w.top.use.list select from $s
2545 $w.top.use.list select to $s
2551 $w.top.use.list yview $s
2553 set lno [lindex [$w.top.use.list curselection] 0]
2554 set i [expr $lno+$lno+1]
2555 set useTmpValue [lindex $attr $i]
2556 dputs "useTmpValue=$useTmpValue"
2560 proc index-setup-action {oldAttr queryNo indexNo} {
2561 set attr [lindex $oldAttr 0]
2564 global relationTmpValue
2565 global structureTmpValue
2566 global truncationTmpValue
2567 global completenessTmpValue
2568 global positionTmpValue
2573 dputs "index-setup-action"
2574 dputs "queryNo $queryNo"
2575 dputs "indexNo $indexNo"
2576 if {$useTmpValue > 0} {
2577 lappend attr "1=$useTmpValue"
2579 if {$relationTmpValue > 0} {
2580 lappend attr "2=$relationTmpValue"
2582 if {$positionTmpValue > 0} {
2583 lappend attr "3=$positionTmpValue"
2585 if {$structureTmpValue > 0} {
2586 lappend attr "4=$structureTmpValue"
2588 if {$truncationTmpValue > 0} {
2589 lappend attr "5=$truncationTmpValue"
2591 if {$completenessTmpValue > 0} {
2592 lappend attr "6=$completenessTmpValue"
2594 dputs "new attr $attr"
2595 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2596 destroy .index-setup
2599 proc index-setup {attr queryNo indexNo} {
2602 global relationTmpValue
2603 global structureTmpValue
2604 global truncationTmpValue
2605 global completenessTmpValue
2606 global positionTmpValue
2608 set relationTmpValue 0
2609 set truncationTmpValue 0
2610 set structureTmpValue 0
2611 set positionTmpValue 0
2612 set completenessTmpValue 0
2618 set n [lindex $attr 0]
2619 wm title $w "Index setup $n"
2623 set len [llength $attr]
2624 for {set i 1} {$i < $len} {incr i} {
2625 set q [lindex $attr $i]
2626 set l [string first = $q]
2628 set t [string range $q 0 [expr $l - 1]]
2629 set v [string range $q [expr $l + 1] end]
2632 { set useTmpValue $v }
2634 { set relationTmpValue $v }
2636 { set positionTmpValue $v }
2638 { set structureTmpValue $v }
2640 { set truncationTmpValue $v }
2642 { set completenessTmpValue $v }
2647 frame $w.top.use -relief ridge -border 2
2648 frame $w.top.relation -relief ridge -border 2
2649 frame $w.top.position -relief ridge -border 2
2650 frame $w.top.structure -relief ridge -border 2
2651 frame $w.top.truncation -relief ridge -border 2
2652 frame $w.top.completeness -relief ridge -border 2
2658 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2660 label $w.top.use.label -text "Use"
2662 listbox $w.top.use.list -width 26 \
2663 -yscrollcommand "$w.top.use.scroll set"
2665 listbox $w.top.use.list -geometry 26x10 \
2666 -yscrollcommand "$w.top.use.scroll set"
2668 scrollbar $w.top.use.scroll -orient vertical -border 1
2669 pack $w.top.use.label -side top -fill x \
2671 pack $w.top.use.list -side left -fill both -expand yes \
2673 pack $w.top.use.scroll -side right -fill y \
2675 $w.top.use.scroll config -command "$w.top.use.list yview"
2679 # Relation Attributes
2681 pack $w.top.relation -pady 6 -padx 6 -side top
2682 label $w.top.relation.label -text "Relation" -width 18
2684 pack $w.top.relation.label $w.top.relation.b -fill x
2686 # Position Attributes
2688 pack $w.top.position -pady 6 -padx 6 -side top
2689 label $w.top.position.label -text "Position" -width 18
2691 pack $w.top.position.label $w.top.position.b -fill x
2693 # Structure Attributes
2695 pack $w.top.structure -pady 6 -padx 6 -side top
2696 label $w.top.structure.label -text "Structure" -width 18
2698 pack $w.top.structure.label $w.top.structure.b -fill x
2700 # Truncation Attributes
2702 pack $w.top.truncation -pady 6 -padx 6 -side top
2703 label $w.top.truncation.label -text "Truncation" -width 18
2705 pack $w.top.truncation.label $w.top.truncation.b -fill x
2707 # Completeness Attributes
2709 pack $w.top.completeness -pady 6 -padx 6 -side top
2710 label $w.top.completeness.label -text "Completeness" -width 18
2712 pack $w.top.completeness.label $w.top.completeness.b -fill x
2715 bottom-buttons $w [list \
2716 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2717 {Cancel} [list destroy $w]] 0
2721 proc query-edit-index {queryNo} {
2725 set i [lindex [$w.top.index.list curselection] 0]
2729 set attr [lindex $queryInfoTmp $i]
2730 dputs "Editing no $i $attr"
2731 index-setup $attr $queryNo $i
2734 proc query-delete-index {queryNo} {
2736 global queryButtonsTmp
2739 set i [lindex [$w.top.index.list curselection] 0]
2743 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2744 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2745 $w.top.index.list delete $i
2748 proc query-setup {queryNo} {
2754 global queryButtonsTmp
2756 global queryIndexTmp
2759 set queryName [lindex $queryTypes $queryNo]
2760 set queryInfoTmp [lindex $queryInfo $queryNo]
2761 set queryButtonsTmp [lindex $queryButtons $queryNo]
2766 wm title $w "Query setup $queryName"
2770 frame $w.top.lines -relief ridge -border 2
2772 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2776 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2778 button $w.top.lines.add -text "Add" \
2779 -command [list query-add-line $queryNo]
2780 button $w.top.lines.del -text "Remove" \
2781 -command [list query-del-line $queryNo]
2783 pack $w.top.lines.del -fill x -side bottom
2784 pack $w.top.lines.add -fill x -pady 10 -side bottom
2788 frame $w.top.index -relief ridge -border 2
2789 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2791 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2792 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2793 -command [list $w.top.index.list yview]
2794 bind $w.top.index.list <Double-1> [list query-edit-index $queryNo]
2796 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2797 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2800 $w.top.index.list selection clear 0 end
2801 $w.top.index.list selection set 0 0
2803 $w.top.index.list select from 0
2804 $w.top.index.list select to 0
2807 foreach x $queryInfoTmp {
2808 $w.top.index.list insert end [lindex $x 0]
2812 bottom-buttons $w [list \
2813 Ok [list query-setup-action $queryNo] \
2814 Add [list query-add-index $queryNo] \
2815 Edit [list query-edit-index $queryNo] \
2816 Delete [list query-delete-index $queryNo] \
2817 Cancel [list destroy $w]] 0
2820 proc index-clear {} {
2821 global queryButtonsFind
2824 foreach b $queryButtonsFind {
2825 .lines.$i.e delete 0 end
2830 proc index-query {} {
2831 global queryButtonsFind
2832 global queryInfoFind
2837 foreach b $queryButtonsFind {
2838 set term [string trim [.lines.$i.e get]]
2840 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
2843 set len [string length $term]
2847 if {[string index $term 0] == ">"} {
2848 if {[string index $term 1] == "=" } {
2849 set term [string trim [string range $term 2 $len]]
2852 set term [string trim [string range $term 1 $len]]
2855 } elseif {[string index $term 0] == "<"} {
2856 if {[string index $term 1] == "=" } {
2857 set term [string trim [string range $term 2 $len]]
2859 } elseif {[string index $term 1] == ">"} {
2860 set term [string trim [string range $term 2 $len]]
2863 set term [string trim [string range $term 1 $len]]
2868 set len [string length $term]
2872 if {[string index $term $len] == "?"} {
2874 set term [string range $term 0 [expr $len - 1]]
2876 if {[string index $term 0] == "?"} {
2878 set term [string range $term 1 end]
2880 set term "\{${term}\}"
2881 if {$right && $left} {
2882 set term "@attr 5=3 ${term}"
2884 set term "@attr 5=1 ${term}"
2886 set term "@attr 5=2 ${term}"
2888 if {$relation != ""} {
2889 set term "@attr 2=${relation} ${term}"
2892 set term "@attr $a ${term}"
2895 set qs "@and ${qs} ${term}"
2906 proc index-focus-in {w i} {
2907 global curIndexEntry
2910 $w.$i configure -background red
2912 set curIndexEntry $i
2915 proc index-lines {w realOp buttonInfo queryInfo handle} {
2917 foreach b $buttonInfo {
2918 if {! [winfo exists $w.$i]} {
2920 frame $w.$i -border 0
2922 frame $w.$i -background white -border 1
2925 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
2928 if {! [winfo exists $w.$i.e]} {
2929 entry $w.$i.e -width 32 -relief sunken -border 1
2930 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
2931 bind $w.$i.e <FocusOut> [list $w.$i configure \
2933 pack $w.$i.l -side left
2934 pack $w.$i.e -side left -fill x -expand yes
2935 pack $w.$i -side top -fill x -padx 2 -pady 2
2937 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2938 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2940 bind $w.$i.e <Return> {search-request 0}
2943 pack $w.$i.l -side left
2944 pack $w.$i -side top -fill x -padx 2 -pady 2
2949 while {[winfo exists $w.$j]} {
2961 bind $w.$j.e <Tab> "focus $w.$k.e"
2967 bind $w.$i.e <Tab> "focus $w.0.e"
2973 proc search-fields {w buttondefs} {
2975 foreach buttondef $buttondefs {
2976 frame $w.$i -background white
2978 listbutton $w.$i.l 0 $buttondef
2979 entry $w.$i.e -width 32 -relief sunken
2981 pack $w.$i.l -side left
2982 pack $w.$i.e -side left -fill x -expand yes
2984 pack $w.$i -side top -fill x -padx 2 -pady 2
2986 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2987 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2995 bind $w.$j.e <Tab> "focus $w.$k.e \n
2996 $w.$k configure -background red \n
2997 $w.$j configure -background white"
3000 bind $w.$i.e <Tab> "focus $w.0.e \n
3001 $w.0 configure -background red \n
3002 $w.$i configure -background white"
3004 $w.0 configure -background red
3007 if {[info exists windowGeometry(.)]} {
3008 set g $windowGeometry(.)
3016 frame .top -border 1 -relief raised
3017 frame .lines -border 1 -relief raised
3018 frame .mid -border 1 -relief raised
3019 frame .data -border 1 -relief raised
3020 frame .bot -border 1 -relief raised
3021 pack .top .lines .mid -side top -fill x
3022 pack .data -side top -fill both -expand yes
3025 menubutton .top.file -text "File" -menu .top.file.m
3027 .top.file.m add command -label "Save settings" -command {save-settings}
3028 .top.file.m add separator
3029 .top.file.m add command -label "Exit" -command {exit-action}
3031 menubutton .top.target -text "Target" -menu .top.target.m
3033 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
3034 .top.target.m add command -label "Disconnect" -command {close-target}
3035 .top.target.m add command -label "About" -command {about-target}
3036 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
3037 .top.target.m add command -label "Setup new" -command {define-target-dialog}
3038 .top.target.m add separator
3039 set-target-hotlist 0
3041 configure-disable-e .top.target.m 1
3042 configure-disable-e .top.target.m 2
3044 menu .top.target.m.clist
3045 menu .top.target.m.slist
3048 menubutton .top.service -text "Service" -menu .top.service.m
3050 .top.service.m add command -label "Database" -command {database-select}
3051 .top.service.m add cascade -label "Present" -menu .top.service.m.present
3052 menu .top.service.m.present
3053 .top.service.m.present add command -label "10 More" \
3054 -command [list present-more 10]
3055 .top.service.m.present add command -label "All" \
3056 -command [list present-more {}]
3057 .top.service.m add command -label "Search" -command {search-request 0}
3058 .top.service.m add command -label "Scan" -command {scan-request}
3060 .top.service configure -state disabled
3062 menubutton .top.rset -text "Set" -menu .top.rset.m
3064 .top.rset.m add command -label "Load" -command {load-set}
3065 .top.rset.m add separator
3067 menubutton .top.options -text "Options" -menu .top.options.m
3069 .top.options.m add cascade -label "Query" -menu .top.options.m.query
3070 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
3071 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
3072 .top.options.m add cascade -label "Syntax" -menu .top.options.m.syntax
3073 .top.options.m add cascade -label "Elements" -menu .top.options.m.elements
3075 menu .top.options.m.query
3076 .top.options.m.query add cascade -label "Select" \
3077 -menu .top.options.m.query.clist
3078 .top.options.m.query add cascade -label "Edit" \
3079 -menu .top.options.m.query.slist
3080 .top.options.m.query add command -label "New" \
3081 -command {query-new}
3082 .top.options.m.query add cascade -label "Delete" \
3083 -menu .top.options.m.query.dlist
3085 menu .top.options.m.query.slist
3086 menu .top.options.m.query.clist
3087 menu .top.options.m.query.dlist
3090 menu .top.options.m.formats
3092 foreach f $displayFormats {
3093 .top.options.m.formats add radiobutton -label $f -value $i \
3094 -command [list set-display-format $i] -variable displayFormat
3098 menu .top.options.m.wrap
3099 .top.options.m.wrap add radiobutton -label "Character" \
3100 -value char -variable textWrap -command {set-wrap char}
3101 .top.options.m.wrap add radiobutton -label "Word" \
3102 -value word -variable textWrap -command {set-wrap word}
3103 .top.options.m.wrap add radiobutton -label "None" \
3104 -value none -variable textWrap -command {set-wrap none}
3106 menu .top.options.m.syntax
3107 .top.options.m.syntax add radiobutton -label "None" \
3108 -value None -variable recordSyntax
3109 .top.options.m.syntax add separator
3110 .top.options.m.syntax add radiobutton -label "USMARC" \
3111 -value USMARC -variable recordSyntax
3112 .top.options.m.syntax add radiobutton -label "UNIMARC" \
3113 -value UNIMARC -variable recordSyntax
3114 .top.options.m.syntax add radiobutton -label "UKMARC" \
3115 -value UKMARC -variable recordSyntax
3116 .top.options.m.syntax add radiobutton -label "DANMARC" \
3117 -value DANMARC -variable recordSyntax
3118 .top.options.m.syntax add radiobutton -label "FINMARC" \
3119 -value FINMARC -variable recordSyntax
3120 .top.options.m.syntax add radiobutton -label "NORMARC" \
3121 -value NORMARC -variable recordSyntax
3122 .top.options.m.syntax add radiobutton -label "PICAMARC" \
3123 -value PICAMARC -variable recordSyntax
3124 .top.options.m.syntax add separator
3125 .top.options.m.syntax add radiobutton -label "SUTRS" \
3126 -value SUTRS -variable recordSyntax
3127 .top.options.m.syntax add separator
3128 .top.options.m.syntax add radiobutton -label "GRS1" \
3129 -value GRS1 -variable recordSyntax
3131 menu .top.options.m.elements
3132 .top.options.m.elements add radiobutton -label "Unspecified" \
3133 -value None -variable elementSetNames
3134 .top.options.m.elements add radiobutton -label "Full" \
3135 -value F -variable elementSetNames
3136 .top.options.m.elements add radiobutton -label "Brief" \
3137 -value B -variable elementSetNames
3139 menubutton .top.help -text "Help" -menu .top.help.m
3142 .top.help.m add command -label "Help on help" \
3143 -command {tkerror "Help on help not available. Sorry"}
3144 .top.help.m add command -label "About" -command {about-origin}
3146 pack .top.file .top.target .top.service .top.rset .top.options -side left
3147 pack .top.help -side right
3149 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
3151 button .mid.search -text Search -command {search-request 0} \
3153 button .mid.scan -text Scan \
3154 -command scan-request -state disabled
3155 button .mid.present -text {Present} -command [list present-more 10] \
3158 button .mid.clear -text Clear -command index-clear
3159 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
3162 text .data.record -height 2 -width 20 -wrap none \
3163 -yscrollcommand [list .data.scroll set] -wrap $textWrap
3164 scrollbar .data.scroll -command [list .data.record yview]
3166 .data.record configure -takefocus 0
3167 .data.scroll configure -takefocus 0
3169 pack .data.scroll -side right -fill y
3170 pack .data.record -expand yes -fill both
3174 .data.record tag configure marc-tag -foreground blue
3175 .data.record tag configure marc-id -foreground red
3177 .data.record tag configure marc-tag -foreground black
3178 .data.record tag configure marc-id -foreground black
3180 .data.record tag configure marc-data -foreground black
3181 .data.record tag configure marc-head \
3182 -font -Adobe-Times-Bold-R-Normal-*-140-* \
3183 -foreground brown -relief raised -borderwidth 1
3184 .data.record tag configure marc-small-head -foreground brown
3185 .data.record tag configure marc-pref \
3186 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3188 .data.record tag configure marc-text \
3189 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3191 .data.record tag configure marc-it \
3192 -font -Adobe-Times-Medium-I-Normal-*-140-* \
3195 button .bot.logo -bitmap @${libdir}/bitmaps/book1 -command cancel-operation
3197 .bot.logo configure -takefocus 0
3200 pack .bot.a -side left -fill x
3201 pack .bot.logo -side right -padx 2 -pady 2 -ipadx 1
3203 message .bot.a.target -text "" -aspect 1000 -border 1
3205 label .bot.a.status -text "Not connected" -width 15 -relief \
3206 sunken -anchor w -border 1
3207 label .bot.a.set -text "" -width 5 -relief \
3208 sunken -anchor w -border 1
3209 label .bot.a.message -text "" -width 15 -relief \
3210 sunken -anchor w -border 1
3212 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
3213 pack .bot.a.status .bot.a.set .bot.a.message \
3214 -side left -padx 2 -pady 2 -ipadx 1 -ipady 1
3216 if {[catch {ir z39}]} {
3217 set e [info sharedlibextension]
3218 puts -nonewline "Loading irtcl$e ..."