1 # IR toolkit for tcl/tk
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
7 # Revision 1.73 1995-10-17 10:58:06 adam
8 # More work on presentation formats.
10 # Revision 1.72 1995/10/16 17:00:52 adam
11 # New setting: elementSetNames.
12 # Various client improvements. Medium presentation format looks better.
14 # Revision 1.71 1995/10/13 15:35:27 adam
15 # Relational operators may be used in search entries - changes
16 # in proc index-query.
18 # Revision 1.70 1995/10/12 14:46:52 adam
19 # Better record popup windows. Next/prev buttons in popup record windows.
20 # The record position in the raw format is much more visible.
22 # Revision 1.69 1995/09/21 13:42:54 adam
25 # Revision 1.68 1995/09/21 13:11:49 adam
26 # Support of dynamic loading.
27 # Test script uses load command if necessary.
29 # Revision 1.67 1995/09/20 14:35:19 adam
32 # Revision 1.66 1995/08/29 15:30:13 adam
33 # Work on GRS records.
35 # Revision 1.65 1995/08/24 15:39:09 adam
38 # Revision 1.64 1995/08/24 15:33:02 adam
41 # Revision 1.63 1995/08/04 13:20:48 adam
42 # Buttons at the bottom are slightly smaller.
44 # Revision 1.62 1995/08/04 11:32:37 adam
45 # More work on output queue. Memory related routines moved
48 # Revision 1.61 1995/07/20 08:09:39 adam
49 # client.tcl: Targets removed from hotTargets list when targets
50 # are removed/modified.
51 # ir-tcl.c: More work on triggerResourceControl.
53 # Revision 1.60 1995/06/30 16:30:19 adam
56 # Revision 1.59 1995/06/29 14:06:25 adam
57 # Another bug in install fixed. Configure searches for more versions of yaz.
59 # Revision 1.58 1995/06/29 12:34:06 adam
60 # IrTcl now works with both tk4.0b4/tcl7.4b4 and tk3.6/tcl7.3
62 # Revision 1.57 1995/06/29 09:20:30 adam
63 # Target entries in cascade menus are sorted.
65 # Revision 1.56 1995/06/27 19:03:48 adam
66 # Bug fix in do_present in ir-tcl.c: p->set_child member weren't set.
67 # nextResultSetPosition used instead of setOffset.
69 # Revision 1.55 1995/06/27 17:10:37 adam
70 # Bug fix: install procedure didn't work on some systems.
71 # Error turned up when clientrc.tcl was't present.
73 # Revision 1.54 1995/06/27 14:41:03 adam
74 # Bug fix in search-response. Didn't always observe non-surrogate diagnostics.
76 # Revision 1.53 1995/06/26 12:40:09 adam
77 # Client defines its own tkerror.
78 # User may specify 'no preferredRecordSyntax'.
80 # Revision 1.52 1995/06/22 13:14:59 adam
81 # Feature: SUTRS. Setting getSutrs implemented.
82 # Work on display formats.
83 # Preferred record syntax can be set by the user.
85 # Revision 1.51 1995/06/21 11:11:00 adam
86 # Bug fix: libdir undefined in about-origin.
88 # Revision 1.50 1995/06/21 11:04:48 adam
89 # Uses GNU autoconf 2.3.
90 # Install procedure implemented.
91 # boook bitmaps moved to sub directory bitmaps.
93 # Revision 1.49 1995/06/20 14:16:42 adam
94 # More work on cancel mechanism.
96 # Revision 1.48 1995/06/20 08:07:23 adam
97 # New setting: failInfo.
98 # Working on better cancel mechanism.
100 # Revision 1.47 1995/06/19 14:05:29 adam
101 # Bug fix: asked for SUTRS.
103 # Revision 1.46 1995/06/19 13:06:06 adam
104 # New define: IR_TCL_VERSION.
106 # Revision 1.45 1995/06/19 08:08:44 adam
107 # client.tcl: hotTargets now contain both database and target name.
108 # ir-tcl.c: setting protocol edited. Errors in callbacks are logged
109 # by logf(LOG_WARN, ...) calls.
111 # Revision 1.44 1995/06/16 14:55:18 adam
112 # Book logo mirrored.
114 # Revision 1.43 1995/06/16 14:41:05 adam
115 # Scan line entries can be copied to a search entry.
117 # Revision 1.42 1995/06/16 12:28:13 adam
118 # Implemented preferredRecordSyntax.
119 # Minor changes in diagnostic handling.
120 # Record list deleted when connection closes.
122 # Revision 1.41 1995/06/14 15:07:59 adam
123 # Bug fix in cascade-target-list. Uses yaz-version.h.
125 # Revision 1.40 1995/06/14 13:37:17 adam
126 # Setting recordType implemented.
127 # Setting implementationVersion implemented.
128 # Settings implementationId / implementationName edited.
130 # Revision 1.39 1995/06/14 12:16:22 adam
131 # hotTargets, textWrap and displayFormat saved in clientg.tcl.
133 # Revision 1.38 1995/06/14 07:22:45 adam
134 # Target definitions can be deleted.
135 # Listbox used in the query definition dialog.
137 # Revision 1.37 1995/06/13 14:37:59 adam
138 # Work on query setup.
139 # Better about origin/target.
140 # Better presentation formats.
142 # Revision 1.36 1995/06/13 07:42:14 adam
143 # Bindings removed from text widgets.
145 # Revision 1.35 1995/06/12 15:17:31 adam
146 # Text widget used in main window (instead of listbox) to support
147 # better presentation formats.
149 # Revision 1.34 1995/06/12 07:59:07 adam
150 # More work on geometry handling.
152 # Revision 1.33 1995/06/09 11:17:35 adam
153 # Start work on geometry management.
155 # Revision 1.32 1995/06/07 09:16:37 adam
156 # New presentation format.
158 # Revision 1.31 1995/06/06 16:31:09 adam
159 # Bug fix: target names couldn't contain blanks.
162 # Revision 1.30 1995/06/06 11:35:41 adam
163 # Work on scan. Display of old sets.
165 # Revision 1.29 1995/06/05 14:11:18 adam
166 # Bug fix in present-more.
168 # Revision 1.28 1995/06/02 14:52:13 adam
169 # Minor changes really.
171 # Revision 1.27 1995/06/02 14:29:42 adam
172 # Work on scan interface - up/down buttons.
174 # Revision 1.26 1995/06/01 16:36:46 adam
175 # About buttons. Minor bug fixes.
177 # Revision 1.25 1995/05/31 13:09:57 adam
178 # Client searches/presents may be interrupted.
179 # New moving book-logo.
181 # Revision 1.24 1995/05/31 08:36:24 adam
182 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
183 # New method: referenceId. More work on scan.
185 # Revision 1.23 1995/05/29 10:33:41 adam
186 # README and rename of startup script.
188 # Revision 1.22 1995/05/26 11:44:09 adam
189 # Bugs fixed. More work on MARC utilities and queries. Test
190 # client is up-to-date again.
192 # Revision 1.21 1995/05/11 15:34:46 adam
193 # Scan request changed a bit. This version works with RLG.
195 # Revision 1.20 1995/04/21 16:31:57 adam
196 # New radiobutton: protocol (z39v2/SR).
198 # Revision 1.19 1995/04/18 16:11:50 adam
199 # First version of graphical Scan. Some work on query-by-form.
201 # Revision 1.18 1995/04/10 10:50:22 adam
202 # Result-set name defaults to suffix of ir-set name.
203 # Started working on scan. Not finished at this point.
205 # Revision 1.17 1995/03/31 09:34:57 adam
206 # Search-button disabled when there is no connection.
208 # Revision 1.16 1995/03/31 08:56:36 adam
209 # New button "Search".
211 # Revision 1.15 1995/03/28 12:45:22 adam
212 # New ir method failback: called on disconnect/protocol error.
213 # New ir set/get method: protocol: SR / Z3950.
214 # Simple popup and disconnect when failback is invoked.
216 # Revision 1.14 1995/03/22 16:07:55 adam
219 # Revision 1.13 1995/03/21 17:27:26 adam
220 # Short-hand keys in setup.
222 # Revision 1.12 1995/03/21 13:41:03 adam
223 # Comstack cs_create not used too often. Non-blocking connect.
225 # Revision 1.11 1995/03/21 10:39:06 adam
226 # Diagnostic error message displayed with tkerror.
228 # Revision 1.10 1995/03/20 15:24:06 adam
229 # Diagnostic records saved on searchResponse.
231 # Revision 1.9 1995/03/17 18:26:16 adam
232 # Non-blocking i/o used now. Database names popup as cascade items.
234 # Revision 1.8 1995/03/17 15:45:00 adam
235 # Improved target/database setup.
237 # Revision 1.7 1995/03/16 17:54:03 adam
238 # Minor changes really.
240 # Revision 1.6 1995/03/15 19:10:20 adam
241 # Database setup in protocol-setup (rather target setup).
243 # Revision 1.5 1995/03/15 13:59:23 adam
246 # Revision 1.4 1995/03/14 17:32:29 adam
247 # Presentation of full Marc record in popup window.
249 # Revision 1.3 1995/03/12 19:31:52 adam
250 # Pattern matching implemented when retrieving MARC records. More
251 # diagnostic functions.
253 # Revision 1.2 1995/03/10 18:00:15 adam
254 # Actual presentation in line-by-line format. RPN query support.
256 # Revision 1.1 1995/03/09 16:15:07 adam
257 # First presentRequest attempts. Hot-target list.
261 if {$tk_version == "3.6"} {
272 proc configure-enable-e {w n} {
274 $w entryconfigure $n -state normal
276 proc configure-disable-e {w n} {
278 $w entryconfigure $n -state disabled
280 set noFocus [list -takefocus 0]
282 proc configure-enable-e {w n} {
285 proc configure-disable-e {w n} {
292 if {[tk colormodel .] == "color"} {
302 if {[file readable bitmaps/book2]} {
305 if {! [file readable ${libdir}/bitmaps/book2]} {
306 puts "Cannot locate system files in ${libdir}. You must either run this"
307 puts "program from the source directory root of ir-tcl or you must assure"
308 puts "that it is installed - normally in /usr/local/lib/irtcl"
316 set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} Z39 1}
318 set settingsChanged 0
326 set recordSyntax None
327 set elementSetNames None
330 set queryTypes {Simple}
331 set queryButtons { { {I 0} {I 1} {I 2} } }
332 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
333 {Subject {1=21}} {Any {1=1016}} } }
342 if {[winfo exists $w]} {
351 label $w.top.b -bitmap error
352 message $w.top.t -aspect 300 -text "Error: $err" \
353 -font -Adobe-Helvetica-Bold-R-Normal-*-180-*
354 pack $w.top.b $w.top.t -side left -padx 10 -pady 10
356 bottom-buttons $w [list {Close} [list destroy $w]] 1
359 proc read-formats {} {
360 global displayFormats
362 if {[catch {set formats [glob -nocomplain ${libdir}/formats/*.tcl]}]} {
363 set formats ./formats/raw.tcl
366 if {[file readable $f]} {
368 set l [string length $f]
369 set f [string range $f [string length "${libdir}/formats/"] \
371 lappend displayFormats $f
380 .data.record configure -wrap $m
386 proc set-display-format {f} {
396 .bot.a.status configure -text "Reformatting"
399 add-title-lines -1 10000 1
402 proc initBindings {} {
405 bind $w <Double-1> {}
406 bind $w <Triple-1> {}
407 bind $w <B1-Motion> {}
409 bind $w <Shift-B1-Motion> {}
411 bind $w <B2-Motion> {}
412 bind $w <Any-KeyPress> {}
414 bind $w <BackSpace> {}
416 bind $w <Control-h> {}
417 bind $w <Control-d> {}
418 bind $w <Control-v> {}
421 bind $w <B1-Motion> {}
422 bind $w <Shift-B1-Motion> {}
427 proc post-menu {wbutton wmenu} {
430 $wmenu post [winfo rootx $wbutton] \
431 [expr [winfo rooty $wbutton]+[winfo height $wbutton]]
436 global windowGeometry
437 set windowGeometry($w) [wm geometry $w]
440 global windowGeometry
443 if {[info exists windowGeometry($w)]} {
444 set g $windowGeometry($w)
449 bind $w <Destroy> [list destroyGW $w]
452 if {[file readable "clientrc.tcl"]} {
453 source "clientrc.tcl"
455 if {[file readable "${libdir}/clientrc.tcl"]} {
456 source "${libdir}/clientrc.tcl"
460 if {[file readable "~/.clientrc.tcl"]} {
461 source "~/.clientrc.tcl"
464 set queryButtonsFind [lindex $queryButtons 0]
465 set queryInfoFind [lindex $queryInfo 0]
467 proc top-down-window {w} {
468 frame $w.top -relief raised -border 1
469 frame $w.bot -relief raised -border 1
471 pack $w.top -side top -fill both -expand yes
472 pack $w.bot -fill both
475 proc top-down-ok-cancel {w ok-action g} {
476 frame $w.bot.left -relief sunken -border 1
477 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 1 -pady 1
478 button $w.bot.left.ok -width 4 -text {Ok} \
479 -command ${ok-action}
480 pack $w.bot.left.ok -expand yes -ipadx 1 -ipady 1 -padx 2 -pady 2
481 button $w.bot.cancel -width 5 -text {Cancel} \
482 -command [list destroy $w]
483 pack $w.bot.cancel -side left -expand yes
491 proc bottom-buttons {w buttonList g} {
493 set l [llength $buttonList]
495 frame $w.bot.$i -relief sunken -border 1
496 pack $w.bot.$i -side left -expand yes -padx 2 -pady 2
497 button $w.bot.$i.ok -text [lindex $buttonList $i] \
498 -command [lindex $buttonList [expr $i+1]]
499 pack $w.bot.$i.ok -expand yes -padx 2 -pady 2 -side left
503 button $w.bot.$i -text [lindex $buttonList $i] \
504 -command [lindex $buttonList [expr $i+1]]
505 pack $w.bot.$i -expand yes -padx 2 -pady 2 -side left
515 proc cancel-operation {} {
523 show-status Cancel 0 1
527 proc show-target {target base} {
531 .bot.a.target configure -text ""
535 .bot.a.target configure -text "$target"
537 .bot.a.target configure -text "$target - $base"
541 proc show-logo {v1} {
550 .bot.logo configure -bitmap @${libdir}/bitmaps/book${v1}
551 after 140 [list show-logo $v1]
555 .bot.logo configure -bitmap @${libdir}/bitmaps/book1
564 proc show-status {status b sb} {
571 .bot.a.status configure -text "$status"
573 if {$busy == 0} {set busy 1}
581 .top.service configure -state normal
582 .mid.search configure -state normal
584 .mid.scan configure -state normal
587 configure-disable-e .top.service.m 1
588 } elseif {[z39.$setNo nextResultSetPosition] > 0 &&
589 [z39.$setNo nextResultSetPosition] <= [z39.$setNo resultCount]} {
590 configure-enable-e .top.service.m 1
591 .mid.present configure -state normal
593 configure-disable-e .top.service.m 1
594 .mid.present configure -state disabled
596 if {[winfo exists .scan-window]} {
597 .scan-window.bot.2 configure -state normal
598 .scan-window.bot.4 configure -state normal
601 .top.service configure -state disabled
602 .mid.search configure -state disabled
603 .mid.scan configure -state disabled
604 .mid.present configure -state disabled
606 if {[winfo exists .scan-window]} {
607 .scan-window.bot.2 configure -state disabled
608 .scan-window.bot.4 configure -state disabled
613 proc show-message {msg} {
614 .bot.a.message configure -text "$msg"
617 proc insertWithTags {w text args} {
618 set start [$w index insert]
619 $w insert insert $text
620 foreach tag [$w tag names $start] {
621 $w tag remove $tag $start insert
624 $w tag add $i $start insert
628 proc popup-license {} {
633 wm title $w "License"
639 text $w.top.t -width 80 -height 10 -wrap word \
640 -yscrollcommand [list $w.top.s set]
641 scrollbar $w.top.s -command [list $w.top.t yview]
643 pack $w.top.s -side right -fill y
644 pack $w.top.t -expand yes -fill both
646 if {[file readable "${libdir}/LICENSE"]} {
647 set f [open "${libdir}/LICENSE" r]
648 while {[gets $f buf] != -1} {
649 $w.top.t insert end $buf
650 $w.top.t insert end "\n"
654 bottom-buttons $w [list {Close} [list destroy $w]] 1
657 proc about-target {} {
658 set w .about-target-w
663 wm title $w "About target"
667 frame $w.top.a -relief ridge -border 2
668 frame $w.top.p -relief ridge -border 2
670 pack $w.top.a $w.top.p -side top -fill x
672 label $w.top.a.about -text "About"
673 label $w.top.a.irtcl -text $hostid \
674 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
675 pack $w.top.a.about $w.top.a.irtcl -side top
677 set i [z39 targetImplementationName]
678 label $w.top.p.in -text "Implementation name: $i"
679 set i [z39 targetImplementationId]
680 label $w.top.p.ii -text "Implementation id: $i"
681 set i [z39 targetImplementationVersion]
682 label $w.top.p.iv -text "Implementation version: $i"
684 label $w.top.p.op -text "Protocol options: $i"
686 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
688 bottom-buttons $w [list {Close} [list destroy $w]] 1
691 proc about-origin-logo {n} {
693 set w .about-origin-w
694 if {![winfo exists $w]} {
701 $w.top.a.logo configure -bitmap @${libdir}/bitmaps/book$n
702 after 140 [list about-origin-logo $n]
705 proc about-origin {} {
706 set w .about-origin-w
710 if {[winfo exists $w]} {
715 wm title $w "About IrTcl"
719 frame $w.top.a -relief ridge -border 2
720 frame $w.top.p -relief ridge -border 2
722 pack $w.top.a $w.top.p -side top -fill x
724 label $w.top.a.irtcl -text "IrTcl" \
725 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
726 label $w.top.a.logo -bitmap @${libdir}/bitmaps/book1
727 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
730 catch {set i [z39 implementationName]}
731 label $w.top.p.in -text "Implementation name: $i"
732 catch {set i [z39 implementationId]}
733 label $w.top.p.ii -text "Implementation id: $i"
734 catch {set i [z39 implementationVersion]}
735 label $w.top.p.iv -text "Implementation version: $i"
737 label $w.top.p.tk -text "Tk version: $i"
739 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.tk -side top -anchor nw
742 bottom-buttons $w [list {Close} [list destroy $w] \
743 {License} [list popup-license]] 0
746 proc popup-marc {sno no b df} {
747 global displayFormats
750 if {[z39.$sno type $no] != "DB"} {
755 while {[winfo exists .full-marc$b]} {
761 if {![winfo exists $w]} {
766 frame $w.top -relief raised -border 1
767 frame $w.bot -relief raised -border 1
769 pack $w.top -side top -fill both -expand yes
770 pack $w.bot -fill both
772 text $w.top.record -width 60 -height 5 -wrap word \
773 -yscrollcommand [list $w.top.s set]
774 scrollbar $w.top.s -command [list $w.top.record yview]
778 $w.top.record tag configure marc-tag -foreground blue
779 $w.top.record tag configure marc-id -foreground red
781 $w.top.record tag configure marc-tag -foreground black
782 $w.top.record tag configure marc-id -foreground black
784 $w.top.record tag configure marc-data -foreground black
785 $w.top.record tag configure marc-head \
786 -font -Adobe-Times-Medium-R-Normal-*-180-* \
787 -background black -foreground white
789 $w.top.record tag configure marc-pref \
790 -font -Adobe-Times-Medium-R-Normal-*-180-* \
792 $w.top.record tag configure marc-text \
793 -font -Adobe-Times-Medium-R-Normal-*-180-* \
795 $w.top.record tag configure marc-it \
796 -font -Adobe-Times-Medium-I-Normal-*-180-* \
799 pack $w.top.s -side right -fill y
800 pack $w.top.record -expand yes -fill both
802 bottom-buttons $w [list \
803 {Close} [list destroy $w] \
807 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m \
809 menu $w.bot.formats.m
810 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 \
811 -padx 3 -pady 3 -side left
813 $w.bot.formats.m delete 0 last
816 foreach f $displayFormats {
817 $w.bot.formats.m add radiobutton -label $f \
818 -variable popupMarcdf -value $i \
819 -command [list popup-marc $sno $no $b 0]
822 $w.top.record delete 0.0 end
823 set recordType [z39.$sno recordType $no]
824 wm title $w "$recordType record #$no"
826 $w.bot.2 configure -command \
827 [list popup-marc $sno [expr $no-1] $b $df]
828 $w.bot.4 configure -command \
829 [list popup-marc $sno [expr $no+1] $b $df]
831 $w.bot.2 configure -state disabled
833 $w.bot.2 configure -state normal
835 if {[z39.$sno type [expr $no+1]] != "DB"} {
836 $w.bot.4 configure -state disabled
838 $w.bot.4 configure -state normal
840 $w.bot.6 configure -command [list popup-marc $sno $no -1 0]
841 set ffunc [lindex $displayFormats $df]
842 set ffunc "display-$ffunc"
844 $ffunc $sno $no $w.top.record 0
847 proc update-target-hotlist {target base} {
850 set olen [llength $hotTargets]
852 foreach e $hotTargets {
853 if {$target == [lindex $e 0] && $base == [lindex $e 1]} {
854 set hotTargets [lreplace $hotTargets $i $i]
859 set hotTargets [linsert $hotTargets 0 [list $target $base]]
860 set-target-hotlist $olen
863 proc delete-target-hotlist {target} {
866 set olen [llength $hotTargets]
868 foreach e $hotTargets {
869 if {$target == [lindex $e 0]} {
870 set hotTargets [lreplace $hotTargets $i $i]
874 set-target-hotlist $olen
877 proc set-target-hotlist {olen} {
882 .top.target.m delete 7 [expr 7+$olen]
884 .top.target.m delete 6 [expr 6+$olen]
888 foreach e $hotTargets {
889 set target [lindex $e 0]
890 set base [lindex $e 1]
892 .top.target.m add command -label "$i $target" -command \
893 [list reopen-target $target {}]
895 .top.target.m add command -label "$i $target - $base" -command \
896 [list reopen-target $target $base]
905 proc reopen-target {target base} {
907 open-target $target $base
908 update-target-hotlist $target $base
911 proc define-target-action {} {
914 set target [.target-define.top.target.entry get]
918 foreach n [array names profile] {
924 set seq [lindex $profile(Default) 12]
926 set profile($target) $profile(Default)
927 set profile(Default) [lreplace $profile(Default) 12 12 [incr seq]]
929 protocol-setup $target
930 destroy .target-define
933 proc fail-response {target} {
934 set c [lindex [z39 failInfo] 0]
935 set m [lindex [z39 failInfo] 1]
940 proc connect-response {target base} {
941 dputs "connect-response"
942 show-target $target $base
946 proc open-target {target base} {
951 z39 comstack [lindex $profile($target) 6]
952 z39 protocol [lindex $profile($target) 11]
953 z39 idAuthentication [lindex $profile($target) 3]
954 z39 maximumRecordSize [lindex $profile($target) 4]
955 z39 preferredMessageSize [lindex $profile($target) 5]
956 dputs "maximumRecordSize="
957 dputs [z39 maximumRecordSize]
958 dputs "preferredMessageSize="
959 dputs [z39 preferredMessageSize]
960 show-status Connecting 1 0
962 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
964 z39 databaseNames $base
966 z39 failback [list fail-response $target]
967 z39 callback [list connect-response $target $base]
970 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
973 tkerror $errorMessage
974 show-status "Not connected" 0 {}
978 configure-disable-e .top.target.m 0
979 configure-enable-e .top.target.m 1
980 configure-enable-e .top.target.m 2
983 proc close-target {} {
992 .bot.a.set configure -text ""
996 show-status {Not connected} 0 0
999 configure-disable-e .top.target.m 1
1000 configure-disable-e .top.target.m 2
1002 .top.rset.m delete 2 last
1004 .top.rset.m delete 1 last
1006 .top.rset.m add separator
1007 configure-enable-e .top.target.m 0
1010 proc load-set-action {} {
1014 ir-set z39.$setNoLast z39
1016 set fname [.load-set.top.filename.entry get]
1019 show-status Loading 1 {}
1021 z39.$setNoLast loadFile $fname
1023 set no [z39.$setNoLast numberOfRecordsReturned]
1024 add-title-lines $setNoLast $no 1
1026 set l [format "%-4d %7d" $setNoLast $no]
1027 .top.rset.m add command -label $l \
1028 -command [list add-title-lines $setNoLast 10000 1]
1029 show-status Ready 0 {}
1035 set oldFocus [focus]
1039 frame $w.top.filename
1040 pack $w.top.filename -side top -anchor e -pady 2
1042 entry-fields $w.top {filename} \
1044 {load-set-action} {destroy .load-set}
1046 top-down-ok-cancel $w {load-set-action} 1
1050 proc init-request {} {
1057 z39 callback {init-response}
1058 show-status Initializing 1 {}
1059 set err [catch {z39 init} errorMessage]
1061 tkerror $errorMessage
1062 show-status Ready 0 {}
1066 proc init-response {} {
1074 if {![z39 initResult]} {
1075 show-status Ready 0 1
1076 set u [z39 userInformationField]
1078 tkerror "Connection rejected by target: $u"
1080 if {[lsearch [z39 options] scan] >= 0} {
1085 show-status Ready 0 1
1089 proc search-request {bflag} {
1098 global elementSetNames
1102 dputs "search-request"
1104 if {!$bflag && $busy} {
1105 dputs "busy: search-request ignored"
1110 show-status Searching 1 0
1111 set delayRequest {search-request 1}
1116 set query [index-query]
1121 set setNo $setNoLast
1122 ir-set z39.$setNo z39
1124 if {[lindex $profile($target) 10] == 1} {
1125 z39.$setNo setName $setNo
1126 dputs "setName=${setNo}"
1128 z39.$setNo setName Default
1129 dputs "setName=Default"
1131 if {[lindex $profile($target) 8] == 1} {
1132 z39.$setNo queryType rpn
1134 if {[lindex $profile($target) 9] == 1} {
1135 z39.$setNo queryType ccl
1139 if {$recordSyntax == "None" } {
1140 z39.$setNo preferredRecordSyntax {}
1142 z39.$setNo preferredRecordSyntax $recordSyntax
1144 if {$elementSetNames == "None" } {
1145 z39.$setNo elementSetNames {}
1147 z39.$setNo elementSetNames $elementSetNames
1149 z39 callback {search-response}
1150 z39.$setNo search $query
1151 show-status Searching 1 0
1154 proc scan-copy {y entry} {
1156 set no [$w.top.list nearest $y]
1158 .lines.$entry.e delete 0 end
1159 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
1162 proc scan-request {} {
1169 global curIndexEntry
1170 global queryButtonsFind
1171 global queryInfoFind
1175 dputs "scan-request"
1178 show-status Scanning 1 0
1179 set delayRequest scan-request
1188 set b [lindex $queryButtonsFind $curIndexEntry]
1190 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
1191 set attr "@attr $a $attr"
1193 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
1194 ir-scan z39.scan z39
1196 if {![winfo exists $w]} {
1203 entry $w.top.entry -relief sunken
1204 pack $w.top.entry -fill x -padx 4 -pady 2
1205 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
1206 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
1208 scrollbar $w.top.scroll -orient vertical -border 1
1209 pack $w.top.list -side left -fill both -expand yes
1210 pack $w.top.scroll -side right -fill y
1211 $w.top.scroll config -command [list $w.top.list yview]
1213 bottom-buttons $w [list {Close} [list destroy $w] \
1214 {Up} [list scan-up $attr] \
1215 {Down} [list scan-down $attr]] 0
1216 bind $w.top.list <Up> [list scan-up $attr]
1217 bind $w.top.list <Down> [list scan-down $attr]
1220 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
1221 wm title $w "Scan $title"
1223 z39 callback [list scan-response $attr 0 35]
1224 z39.scan numberOfTermsRequested 5
1225 z39.scan preferredPositionInResponse 1
1226 z39.scan scan "${attr} 0"
1228 show-status Scanning 1 0
1231 proc scan-term-h {attr} {
1239 set nScanTerm [$w.top.entry get]
1240 if {$nScanTerm == $scanTerm} {
1243 set scanTerm $nScanTerm
1244 z39 callback [list scan-response $attr 0 35]
1245 z39.scan numberOfTermsRequested 5
1246 z39.scan preferredPositionInResponse 1
1247 dputs "${attr} \{${scanTerm}\}"
1248 if {$scanTerm == ""} {
1249 z39.scan scan "${attr} 0"
1251 z39.scan scan "${attr} \{${scanTerm}\}"
1253 show-status Scanning 1 0
1256 proc scan-response {attr start toget} {
1263 dputs "In scan-response"
1264 set m [z39.scan numberOfEntriesReturned]
1270 if {![winfo exists .scan-window]} {
1273 dputs "Handling cancel"
1274 if {$delayRequest != ""} {
1279 show-status Ready 0 1
1282 set nScanTerm [$w.top.entry get]
1283 if {$nScanTerm != $scanTerm} {
1284 z39 callback [list scan-response $attr 0 35]
1285 z39.scan numberOfTermsRequested 5
1286 z39.scan preferredPositionInResponse 1
1287 set scanTerm $nScanTerm
1288 dputs "${attr} \{${scanTerm}\}"
1289 if {$scanTerm == ""} {
1290 z39.scan scan "${attr} 0"
1292 z39.scan scan "${attr} \{${scanTerm}\}"
1294 show-status Scanning 1 0
1297 set status [z39.scan scanStatus]
1300 show-status Ready 0 1
1305 for {set i 0} {$i < $m} {incr i} {
1306 set term [lindex [z39.scan scanLine $i] 1]
1307 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1308 $w.top.list insert $i "$nostr $term"
1311 $w.top.list yview $scanView
1313 $w.top.list delete $start end
1314 for {set i 0} {$i < $m} {incr i} {
1315 set term [lindex [z39.scan scanLine $i] 1]
1316 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1317 $w.top.list insert end "$nostr $term"
1321 dputs "Handling cancel"
1323 if {$delayRequest != ""} {
1329 if {$toget > 0 && $m > 1 && $m < $toget} {
1330 set ntoget [expr $toget - $m + 1]
1331 dputs ntoget=$ntoget
1332 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1334 dputs "down continue: $q"
1336 z39.scan numberOfTermsRequested 10
1338 z39.scan numberOfTermsRequested $ntoget
1340 z39.scan preferredPositionInResponse 1
1341 dputs "${attr} \{$q\}"
1342 z39.scan scan "${attr} \{$q\}"
1345 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1346 set ntoget [expr - $toget - $m]
1347 dputs ntoget=$ntoget
1348 z39 callback [list scan-response $attr 0 -$ntoget]
1349 set q [string range [$w.top.list get 0] 8 end]
1350 dputs "up continue: $q"
1352 z39.scan numberOfTermsRequested 10
1353 z39.scan preferredPositionInResponse 11
1355 z39.scan numberOfTermsRequested $ntoget
1356 z39.scan preferredPositionInResponse [incr ntoget]
1358 dputs "${attr} \{$q\}"
1359 z39.scan scan "${attr} \{$q\}"
1362 show-status Ready 0 1
1365 proc scan-down {attr} {
1373 show-status {Scanning down} 1 0
1374 set delayRequest [list scan-down $attr]
1380 set scanView [expr $scanView + 5]
1381 set s [$w.top.list size]
1382 if {$scanView > $s} {
1383 z39 callback [list scan-response $attr [expr $s - 1] 25]
1384 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1386 z39.scan numberOfTermsRequested 10
1387 z39.scan preferredPositionInResponse 1
1388 show-status Scanning 1 0
1389 dputs "${attr} \{$q\}"
1390 z39.scan scan "${attr} \{$q\}"
1393 $w.top.list yview $scanView
1396 proc scan-up {attr} {
1404 show-status Scanning 1 0
1405 set delayRequest [list scan-up $attr]
1411 set scanView [expr $scanView - 5]
1412 if {$scanView < 0} {
1413 z39 callback [list scan-response $attr 0 -25]
1414 set q [string range [$w.top.list get 0] 8 end]
1416 z39.scan numberOfTermsRequested 10
1417 z39.scan preferredPositionInResponse 11
1418 show-status Scanning 1 0
1419 z39.scan scan "${attr} \{$q\}"
1422 $w.top.list yview $scanView
1425 proc search-response {} {
1433 dputs "In search-response"
1435 dputs "Handling cancel"
1437 if {$delayRequest != ""} {
1445 set setMax [z39.$setNo resultCount]
1446 show-status Ready 0 1
1447 set status [z39.$setNo responseStatus]
1448 if {[lindex $status 0] == "NSD"} {
1449 z39.$setNo nextResultSetPosition 0
1450 set code [lindex $status 1]
1451 set msg [lindex $status 2]
1452 set addinfo [lindex $status 3]
1453 tkerror "NSD$code: $msg: $addinfo"
1456 show-message "${setMax} hits"
1461 show-status Ready 0 1
1462 set l [format "%-4d %7d" $setNo $setMax]
1463 .top.rset.m add command -label $l \
1464 -command [list add-title-lines $setNo 10000 1]
1468 z39 callback {present-response}
1469 z39.$setNo present $setOffset 1
1470 show-status Retrieving 1 0
1473 proc present-more {number} {
1481 dputs "present-more"
1483 show-status Retrieving 1 0
1484 set delayRequest "present-more $number"
1490 dputs "setNo=$setNo"
1493 set setOffset [z39.$setNo nextResultSetPosition]
1494 dputs "setOffest=${setOffset}"
1495 dputs "setNo=${setNo}"
1496 set max [z39.$setNo resultCount]
1497 if {$max < $setOffset} {
1499 dputs "setOffset=$setOffset"
1500 show-status Ready 0 1
1503 if {$number == ""} {
1507 if {$setMax > $max} {
1511 z39 callback {present-response}
1513 set toGet [expr $setMax - $setOffset + 1]
1520 z39.$setNo present $setOffset $toGet
1521 show-status Retrieving 1 0
1524 proc init-title-lines {} {
1525 .data.record delete 0.0 end
1528 proc add-title-lines {setno no offset} {
1529 global displayFormats
1530 global displayFormat
1540 .bot.a.set configure -text $setno
1541 .data.record delete 0.0 end
1543 set ffunc [lindex $displayFormats $displayFormat]
1544 dputs "ffunc=$ffunc"
1545 set ffunc "display-$ffunc"
1546 for {set i 0} {$i < $no} {incr i} {
1547 set o [expr $i + $offset]
1548 set type [z39.$setno type $o]
1552 .data.record tag bind r$o <Any-Enter> {}
1553 .data.record tag bind r$o <Any-Leave> {}
1554 set insert0 [.data.record index insert]
1555 $ffunc $setno $o .data.record 1
1556 .data.record tag add r$o $insert0 insert
1557 .data.record tag bind r$o <1> \
1558 [list popup-marc $setno $o 0 0]
1562 show-status Ready 0 1
1566 proc present-response {} {
1573 dputs "In present-response"
1574 set no [z39.$setNo numberOfRecordsReturned]
1575 dputs "Returned $no records, setOffset $setOffset"
1576 add-title-lines $setNo $no $setOffset
1577 set setOffset [expr $setOffset + $no]
1579 dputs "Handling cancel"
1581 if {$delayRequest != ""} {
1586 set status [z39.$setNo responseStatus]
1587 if {[lindex $status 0] == "NSD"} {
1588 show-status Ready 0 1
1589 set code [lindex $status 1]
1590 set msg [lindex $status 2]
1591 set addinfo [lindex $status 3]
1592 tkerror "NSD$code: $msg: $addinfo"
1595 if {$no > 0 && $setOffset <= $setMax} {
1596 dputs "present-request from ${setOffset}"
1597 set toGet [expr $setMax - $setOffset + 1]
1601 z39.$setNo present $setOffset $toGet
1603 show-status Ready 0 1
1607 proc left-cursor {w} {
1608 set i [$w index insert]
1616 proc right-cursor {w} {
1617 set i [$w index insert]
1623 proc bind-fields {list returnAction escapeAction} {
1624 set max [expr [llength $list]-1]
1625 for {set i 0} {$i < $max} {incr i} {
1626 bind [lindex $list $i] <Return> $returnAction
1627 bind [lindex $list $i] <Escape> $escapeAction
1629 bind [lindex $list $i] <Tab> \
1630 [list focus [lindex $list [expr $i+1]]]
1631 bind [lindex $list $i] <Left> \
1632 [list left-cursor [lindex $list $i]]
1633 bind [lindex $list $i] <Right> \
1634 [list right-cursor [lindex $list $i]]
1637 bind [lindex $list $i] <Return> $returnAction
1638 bind [lindex $list $i] <Escape> $escapeAction
1640 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1641 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1642 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1644 focus [lindex $list 0]
1647 proc entry-fields {parent list tlist returnAction escapeAction} {
1650 foreach field $list {
1651 set label ${parent}.${field}.label
1652 set entry ${parent}.${field}.entry
1653 label $label -text [lindex $tlist $i] -anchor e
1654 entry $entry -width 32 -relief sunken
1655 pack $label -side left
1656 pack $entry -side right
1657 lappend alist $entry
1660 bind-fields $alist $returnAction $escapeAction
1663 proc define-target-dialog {} {
1664 set w .target-define
1670 pack $w.top.target \
1671 -side top -anchor e -pady 2
1672 entry-fields $w.top {target} \
1674 {define-target-action} {destroy .target-define}
1675 top-down-ok-cancel $w {define-target-action} 1
1678 proc protocol-setup-delete {target} {
1680 global settingsChanged
1682 set a [alert "Are you sure you want to delete the target \
1683 definition $target ?"]
1685 set wno [lindex $profile($target) 12]
1688 unset profile($target)
1689 set settingsChanged 1
1691 delete-target-hotlist $target
1695 proc protocol-setup-action {target} {
1698 global protocolRadioType
1699 global settingsChanged
1702 global ResultSetCheck
1704 set wno [lindex $profile($target) 12]
1708 set settingsChanged 1
1709 set len [$w.top.databases.list size]
1710 for {set i 0} {$i < $len} {incr i} {
1711 lappend b [$w.top.databases.list get $i]
1713 set profile($target) [list [$w.top.description.entry get] \
1714 [$w.top.host.entry get] \
1715 [$w.top.port.entry get] \
1716 [$w.top.idAuthentication.entry get] \
1717 [$w.top.maximumRecordSize.entry get] \
1718 [$w.top.preferredMessageSize.entry get] \
1724 $protocolRadioType \
1728 delete-target-hotlist $target
1729 dputs $profile($target)
1733 proc place-force {window parent} {
1734 set g [wm geometry $parent]
1736 set p1 [string first + $g]
1737 set p2 [string last + $g]
1739 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1740 set y [expr 60+[string range $g [expr $p2 +1] end]]
1741 wm geometry $window +${x}+${y}
1744 proc add-database-action {target} {
1747 set wno [lindex $profile($target) 12]
1750 $w.top.databases.list insert end \
1751 [.database-select.top.database.entry get]
1752 destroy .database-select
1755 proc add-database {target} {
1758 set w .database-select
1760 set oldFocus [focus]
1762 set wno [lindex $profile($target) 12]
1763 place-force $w .setup-${wno}
1767 frame $w.top.database
1769 pack $w.top.database -side top -anchor e -pady 2
1771 entry-fields $w.top {database} \
1772 {{Database to add:}} \
1773 [list add-database-action $target] {destroy .database-select}
1775 top-down-ok-cancel $w [list add-database-action $target] 1
1779 proc delete-database {target} {
1782 set wno [lindex $profile($target) 12]
1785 foreach i [$w.top.databases.list curselection] {
1786 set b [$w.top.databases.list get $i]
1789 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1791 foreach i [lsort -decreasing \
1792 [$w.top.databases.list curselection]] {
1793 $w.top.databases.list delete $i
1798 proc protocol-setup {target} {
1801 global protocolRadioType
1804 global ResultSetCheck
1807 set wno [lindex $profile($target) 12]
1811 while {[winfo exists .setup-$b]} {
1819 wm title $w "Setup $target"
1823 if {$target == ""} {
1827 dputs $profile($target)
1829 frame $w.top.description
1832 frame $w.top.idAuthentication
1833 frame $w.top.maximumRecordSize
1834 frame $w.top.preferredMessageSize
1835 frame $w.top.cs-type -relief ridge -border 2
1836 frame $w.top.protocol -relief ridge -border 2
1837 frame $w.top.query -relief ridge -border 2
1838 frame $w.top.databases -relief ridge -border 2
1840 # Maximum/preferred/idAuth ...
1841 pack $w.top.description $w.top.host $w.top.port \
1842 $w.top.idAuthentication $w.top.maximumRecordSize \
1843 $w.top.preferredMessageSize -side top -anchor e -pady 2
1845 entry-fields $w.top {description host port idAuthentication \
1846 maximumRecordSize preferredMessageSize} \
1847 {{Description:} {Host:} {Port:} {Id Authentication:} \
1848 {Maximum Record Size:} {Preferred Message Size:}} \
1849 [list protocol-setup-action $target] [list destroy $w]
1851 foreach sub {description host port idAuthentication \
1852 maximumRecordSize preferredMessageSize} {
1854 bind $w.top.$sub.entry <Control-a> [list add-database $target]
1855 bind $w.top.$sub.entry <Control-d> [list delete-database $target]
1857 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1858 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1859 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1860 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1861 $w.top.maximumRecordSize.entry insert 0 [lindex $profile($target) 4]
1862 $w.top.preferredMessageSize.entry insert 0 [lindex $profile($target) 5]
1863 set csRadioType [lindex $profile($target) 6]
1864 set RPNCheck [lindex $profile($target) 8]
1865 set CCLCheck [lindex $profile($target) 9]
1866 set ResultSetCheck [lindex $profile($target) 10]
1867 set protocolRadioType [lindex $profile($target) 11]
1868 if {$protocolRadioType == ""} {
1869 set protocolRadioType Z39
1873 pack $w.top.databases -side left -pady 2 -padx 2 -expand yes -fill both
1875 label $w.top.databases.label -text "Databases"
1876 button $w.top.databases.add -text "Add" \
1877 -command [list add-database $target]
1878 button $w.top.databases.delete -text "Delete" \
1879 -command [list delete-database $target]
1881 listbox $w.top.databases.list -geometry 14x6 \
1882 -yscrollcommand "$w.top.databases.scroll set"
1884 listbox $w.top.databases.list -width 14 -height 5\
1885 -yscrollcommand "$w.top.databases.scroll set"
1887 scrollbar $w.top.databases.scroll -orient vertical -border 1
1888 pack $w.top.databases.label -side top -fill x \
1890 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1892 pack $w.top.databases.list -side left -fill both -expand yes \
1894 pack $w.top.databases.scroll -side right -fill y \
1896 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1898 foreach b [lindex $profile($target) 7] {
1899 $w.top.databases.list insert end $b
1903 pack $w.top.cs-type -pady 2 -padx 2 -side top -fill x
1905 label $w.top.cs-type.label -text "Transport"
1906 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1907 -variable csRadioType -value tcpip
1908 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1909 -variable csRadioType -value mosi
1911 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1912 -padx 2 -side top -fill x
1915 pack $w.top.protocol -pady 2 -padx 2 -side top -fill x
1917 label $w.top.protocol.label -text "Protocol"
1918 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1919 -variable protocolRadioType -value Z39
1920 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1921 -variable protocolRadioType -value SR
1923 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1924 -padx 2 -side top -fill x
1927 pack $w.top.query -pady 2 -padx 2 -side top -fill x
1929 label $w.top.query.label -text "Query support"
1930 checkbutton $w.top.query.c1 -text "RPN query" -anchor w -variable RPNCheck
1931 checkbutton $w.top.query.c2 -text "CCL query" -anchor w -variable CCLCheck
1932 checkbutton $w.top.query.c3 -text "Result sets" -anchor w -variable ResultSetCheck
1934 pack $w.top.query.label -side top
1935 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
1936 -padx 2 -side top -fill x
1939 bottom-buttons $w [list {Ok} [list protocol-setup-action $target] \
1940 {Delete} [list protocol-setup-delete $target] \
1941 {Cancel} [list destroy $w]] 0
1944 proc database-select-action {} {
1945 set w .database-select.top
1947 foreach indx [$w.databases.list curselection] {
1948 lappend b [$w.databases.list get $indx]
1951 z39 databaseNames $b
1953 destroy .database-select
1956 proc database-select {} {
1957 set w .database-select
1962 set oldFocus [focus]
1967 frame $w.top.databases -relief ridge -border 2
1969 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
1971 label $w.top.databases.label -text "List"
1972 listbox $w.top.databases.list -width 20 -height 6 \
1973 -yscrollcommand "$w.top.databases.scroll set"
1974 scrollbar $w.top.databases.scroll -orient vertical -border 1
1975 pack $w.top.databases.label -side top -fill x \
1977 pack $w.top.databases.list -side left -fill both -expand yes \
1979 pack $w.top.databases.scroll -side right -fill y \
1981 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1983 foreach b [lindex $profile($hostid) 7] {
1984 $w.top.databases.list insert end $b
1986 top-down-ok-cancel $w {database-select-action} 1
1990 proc cascade-target-list {} {
1993 foreach sub [winfo children .top.target.m.clist] {
1996 .top.target.m.clist delete 0 last
1997 foreach n [lsort [array names profile]] {
1998 if {$n != "Default"} {
1999 set nl [lindex $profile($n) 12]
2000 if {[llength [lindex $profile($n) 7]] > 1} {
2001 .top.target.m.clist add cascade -label $n \
2002 -menu .top.target.m.clist.$nl
2003 menu .top.target.m.clist.$nl
2004 foreach b [lindex $profile($n) 7] {
2005 .top.target.m.clist.$nl add command -label $b \
2006 -command [list reopen-target $n $b]
2009 .top.target.m.clist add command -label $n \
2010 -command [list reopen-target $n {}]
2014 .top.target.m.slist delete 0 last
2015 foreach n [lsort [array names profile]] {
2016 if {$n != "Default"} {
2017 .top.target.m.slist add command -label $n \
2018 -command [list protocol-setup $n]
2023 proc query-select {i} {
2024 global queryButtonsFind
2025 global queryInfoFind
2029 set queryInfoFind [lindex $queryInfo $i]
2030 set queryButtonsFind [lindex $queryButtons $i]
2032 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2035 proc query-new-action {} {
2039 global settingsChanged
2041 set settingsChanged 1
2042 lappend queryTypes [.query-new.top.index.entry get]
2043 lappend queryButtons {}
2044 lappend queryInfo {}
2054 set oldFocus [focus]
2059 -side top -anchor e -pady 2
2060 entry-fields $w.top index \
2062 query-new-action {destroy .query-new}
2063 top-down-ok-cancel $w query-new-action 1
2067 proc query-delete-action {queryNo} {
2071 global settingsChanged
2073 set settingsChanged 1
2075 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
2076 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
2077 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
2078 destroy .query-delete
2082 proc query-delete {queryNo} {
2090 set n [lindex $queryTypes $queryNo]
2092 label $w.top.warning -bitmap warning
2093 message $w.top.quest -text "Are you sure you want to delete the \
2094 query type $n ?" -aspect 300
2095 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
2096 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
2097 {Cancel} [list destroy $w]] 1
2100 proc cascade-query-list {} {
2102 set w .top.options.m.query
2105 $w.slist delete 0 last
2106 foreach n $queryTypes {
2107 $w.slist add command -label $n -command [list query-setup $i]
2112 $w.clist delete 0 last
2113 foreach n $queryTypes {
2114 $w.clist add command -label $n -command [list query-select $i]
2118 $w.dlist delete 0 last
2119 foreach n $queryTypes {
2120 $w.dlist add command -label $n -command [list query-delete $i]
2125 proc save-geometry {} {
2126 global windowGeometry
2129 global displayFormat
2132 global elementSetNames
2134 set windowGeometry(.) [wm geometry .]
2136 if {[catch {set f [open ~/.clientrc.tcl w]}]} {
2139 puts $f "set hotTargets \{ $hotTargets \}"
2140 puts $f "set textWrap $textWrap"
2141 puts $f "set displayFormat $displayFormat"
2142 puts $f "set popupMarcdf $popupMarcdf"
2143 puts $f "set recordSyntax $recordSyntax"
2144 puts $f "set elementSetNames $elementSetNames"
2145 foreach n [array names windowGeometry] {
2146 puts -nonewline $f "set \{windowGeometry($n)\} \{"
2147 puts -nonewline $f $windowGeometry($n)
2153 proc save-settings {} {
2156 global settingsChanged
2161 if {![file writable "${libdir}/clientrc.tcl"]} {
2162 set a [alert "Cannot open ${libdir}/clientrc.tcl for writing. Do you \
2163 wish to save clientrc.tcl in the current directory instead?"]
2167 set f [open "clientrc.tcl" w]
2169 set f [open "${libdir}/clientrc.tcl" w]
2171 puts $f "# Setup file"
2173 foreach n [array names profile] {
2174 puts -nonewline $f "set \{profile($n)\} \{"
2175 puts -nonewline $f $profile($n)
2178 puts -nonewline $f "set queryTypes \{"
2179 puts -nonewline $f $queryTypes
2182 puts -nonewline $f "set queryButtons \{"
2183 puts -nonewline $f $queryButtons
2186 puts -nonewline $f "set queryInfo \{"
2187 puts -nonewline $f $queryInfo
2190 set settingsChanged 0
2199 set oldFocus [focus]
2203 label $w.top.warning -bitmap warning
2204 message $w.top.message -text $ask -aspect 300 \
2205 -font -Adobe-Times-Medium-R-Normal-*-180-*
2207 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
2210 top-down-ok-cancel $w {alert-action} 1
2215 proc alert-action {} {
2221 proc exit-action {} {
2222 global settingsChanged
2224 if {$settingsChanged} {
2225 set a [alert "you haven't saved your settings. Do you wish to save?"]
2234 proc listbuttonaction {w name h user i} {
2235 $w configure -text [lindex $name 0]
2236 $h [lindex $name 1] $user $i
2239 proc listbuttonx {button no names handle user} {
2240 if {[winfo exists $button]} {
2241 $button configure -text [lindex [lindex $names $no] 0]
2242 ${button}.m delete 0 last
2244 menubutton $button -text [lindex [lindex $names $no] 0] \
2245 -width 10 -menu ${button}.m -relief raised -border 1
2249 foreach name $names {
2250 ${button}.m add command -label [lindex $name 0] \
2251 -command [list listbuttonaction ${button} $name \
2257 proc listbutton {button no names} {
2258 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
2259 -relief raised -border 1
2261 foreach name $names {
2262 ${button}.m add command -label $name \
2263 -command [list ${button} configure -text $name]
2267 proc listbuttonv-action {button var names i} {
2270 set $var [lindex $names [expr $i+1]]
2271 $button configure -text [lindex $names $i]
2274 proc listbuttonv {button var names} {
2278 eval "set val $$var"
2279 set l [llength $names]
2280 for {set i 1} {$i < $l} {incr i 2} {
2281 if {$val == [lindex $names $i]} {
2283 set n [lindex $names $i]
2287 if {[winfo exists $button]} {
2288 $button configure -text $n
2291 menubutton $button -text $n -menu ${button}.m \
2292 -relief raised -border 1
2294 for {set i 0} {$i < $l} {incr i 2} {
2295 ${button}.m add command -label [lindex $names $i] \
2296 -command [list listbuttonv-action $button $var $names $i]
2300 proc query-add-index-action {queryNo} {
2304 global queryButtonsTmp
2306 set newI [.query-add-index.top.index.entry get]
2307 lappend queryInfoTmp [list $newI {}]
2308 $w.top.index.list insert end $newI
2309 destroy .query-add-index
2310 #destroy $w.top.lines
2311 #frame $w.top.lines -relief ridge -border 2
2312 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2313 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2316 proc query-add-line {queryNo} {
2320 global queryButtonsTmp
2322 lappend queryButtonsTmp {I 0}
2324 #destroy $w.top.lines
2325 #frame $w.top.lines -relief ridge -border 2
2326 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2327 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2330 proc query-del-line {queryNo} {
2334 global queryButtonsTmp
2336 set l [llength $queryButtonsTmp]
2341 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
2342 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2345 proc query-add-index {queryNo} {
2346 set w .query-add-index
2349 set oldFocus [focus]
2350 place-force $w .query-setup
2354 -side top -anchor e -pady 2
2355 entry-fields $w.top {index} \
2357 [list query-add-index-action $queryNo] [list destroy $w]
2358 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
2362 proc query-setup-action {queryNo} {
2365 global queryButtonsTmp
2367 global queryButtonsFind
2368 global queryInfoFind
2370 global settingsChanged
2372 set settingsChanged 1
2374 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
2376 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
2378 set queryInfoFind $queryInfoTmp
2379 set queryButtonsFind $queryButtonsTmp
2381 destroy .query-setup
2382 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2385 proc activate-e-index {value no i} {
2386 global queryButtonsTmp
2387 global queryIndexTmp
2389 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
2390 dputs $queryButtonsTmp
2391 set queryIndexTmp $i
2394 proc activate-index {value no i} {
2395 global queryButtonsFind
2397 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
2399 dputs "queryButtonsFind $queryButtonsFind"
2402 proc update-attr {} {
2404 listbuttonv $w.top.relation.b relationTmpValue\
2405 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
2406 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
2407 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
2408 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
2409 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
2410 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
2411 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
2412 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
2413 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
2414 {local-number} 107 {string} 108 {numeric string} 109}
2415 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2416 {Left} 2 {Left and right} 3 {No truncation} 100 \
2417 {Process #} 101 {Re-1} 102 {Re-2} 103}
2418 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2419 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2422 proc use-attr {init} {
2434 {BNB card number} 10
2435 {BGF(sic) number} 11
2437 {Dewey classification} 13
2438 {UDC classification} 14
2439 {Bliss classification} 15
2441 {NLM call number} 17
2442 {NAL call number} 18
2443 {MOS call number} 19
2444 {Local classification} 20
2445 {Subject heading} 21
2447 {BDI-index-subject} 23
2451 {LC-subject-heading} 27
2452 {RVM-subject-heading} 28
2453 {Local subject index} 29
2455 {Date of publication} 31
2456 {Date of acquisition} 32
2458 {Title-collective} 34
2461 {Title-added-title-page} 37
2465 {Title-other-variant} 41
2467 {Title-abbreviated} 43
2471 {Subject-subdivision} 47
2472 {Number-natl-bibliography} 48
2473 {Number-legal-deposit} 49
2474 {Number-govt-publication} 50
2475 {Number-publisher-for-music} 51
2477 {Number-local-call} 53
2479 {Code-geographic-area} 55
2480 {Code-institution} 56
2482 {Name-geographic} 58
2483 {Place-publication} 59
2485 {Microform-generation} 61
2492 {Author-name-personal} 1004
2493 {Author-name-corporate} 1005
2494 {Author-name-conference} 1006
2495 {Identifier-standard} 1007
2496 {Subject-LC-children's} 1008
2497 {Subject-name-personal} 1009
2499 {Date/time added to database} 1011
2500 {Date/time last modified} 1012
2501 {Authority/format identifier} 1013
2503 {Concept-reference} 1015
2505 {Server choice} 1017
2507 {Record source} 1019
2510 {Geographic class} 1022
2514 {Related periodical} 1026
2515 {Report number} 1027
2517 {Thematic number} 1030
2518 {Material type} 1031
2526 set l [llength $attr]
2531 for {set i 0} {$i < $l} {incr i} {
2532 $w.top.use.list insert end [lindex $attr $i]
2534 if {$useTmpValue == [lindex $attr $i]} {
2540 $w.top.use.list selection clear 0 end
2541 $w.top.use.list selection set $s $s
2543 $w.top.use.list select from $s
2544 $w.top.use.list select to $s
2550 $w.top.use.list yview $s
2552 set lno [lindex [$w.top.use.list curselection] 0]
2553 set i [expr $lno+$lno+1]
2554 set useTmpValue [lindex $attr $i]
2555 dputs "useTmpValue=$useTmpValue"
2559 proc index-setup-action {oldAttr queryNo indexNo} {
2560 set attr [lindex $oldAttr 0]
2563 global relationTmpValue
2564 global structureTmpValue
2565 global truncationTmpValue
2566 global completenessTmpValue
2567 global positionTmpValue
2572 dputs "index-setup-action"
2573 dputs "queryNo $queryNo"
2574 dputs "indexNo $indexNo"
2575 if {$useTmpValue > 0} {
2576 lappend attr "1=$useTmpValue"
2578 if {$relationTmpValue > 0} {
2579 lappend attr "2=$relationTmpValue"
2581 if {$positionTmpValue > 0} {
2582 lappend attr "3=$positionTmpValue"
2584 if {$structureTmpValue > 0} {
2585 lappend attr "4=$structureTmpValue"
2587 if {$truncationTmpValue > 0} {
2588 lappend attr "5=$truncationTmpValue"
2590 if {$completenessTmpValue > 0} {
2591 lappend attr "6=$completenessTmpValue"
2593 dputs "new attr $attr"
2594 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2595 destroy .index-setup
2598 proc index-setup {attr queryNo indexNo} {
2601 global relationTmpValue
2602 global structureTmpValue
2603 global truncationTmpValue
2604 global completenessTmpValue
2605 global positionTmpValue
2607 set relationTmpValue 0
2608 set truncationTmpValue 0
2609 set structureTmpValue 0
2610 set positionTmpValue 0
2611 set completenessTmpValue 0
2617 set n [lindex $attr 0]
2618 wm title $w "Index setup $n"
2622 set len [llength $attr]
2623 for {set i 1} {$i < $len} {incr i} {
2624 set q [lindex $attr $i]
2625 set l [string first = $q]
2627 set t [string range $q 0 [expr $l - 1]]
2628 set v [string range $q [expr $l + 1] end]
2631 { set useTmpValue $v }
2633 { set relationTmpValue $v }
2635 { set positionTmpValue $v }
2637 { set structureTmpValue $v }
2639 { set truncationTmpValue $v }
2641 { set completenessTmpValue $v }
2646 frame $w.top.use -relief ridge -border 2
2647 frame $w.top.relation -relief ridge -border 2
2648 frame $w.top.position -relief ridge -border 2
2649 frame $w.top.structure -relief ridge -border 2
2650 frame $w.top.truncation -relief ridge -border 2
2651 frame $w.top.completeness -relief ridge -border 2
2657 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2659 label $w.top.use.label -text "Use"
2661 listbox $w.top.use.list -width 26 \
2662 -yscrollcommand "$w.top.use.scroll set"
2664 listbox $w.top.use.list -geometry 26x10 \
2665 -yscrollcommand "$w.top.use.scroll set"
2667 scrollbar $w.top.use.scroll -orient vertical -border 1
2668 pack $w.top.use.label -side top -fill x \
2670 pack $w.top.use.list -side left -fill both -expand yes \
2672 pack $w.top.use.scroll -side right -fill y \
2674 $w.top.use.scroll config -command "$w.top.use.list yview"
2678 # Relation Attributes
2680 pack $w.top.relation -pady 6 -padx 6 -side top
2681 label $w.top.relation.label -text "Relation" -width 18
2683 pack $w.top.relation.label $w.top.relation.b -fill x
2685 # Position Attributes
2687 pack $w.top.position -pady 6 -padx 6 -side top
2688 label $w.top.position.label -text "Position" -width 18
2690 pack $w.top.position.label $w.top.position.b -fill x
2692 # Structure Attributes
2694 pack $w.top.structure -pady 6 -padx 6 -side top
2695 label $w.top.structure.label -text "Structure" -width 18
2697 pack $w.top.structure.label $w.top.structure.b -fill x
2699 # Truncation Attributes
2701 pack $w.top.truncation -pady 6 -padx 6 -side top
2702 label $w.top.truncation.label -text "Truncation" -width 18
2704 pack $w.top.truncation.label $w.top.truncation.b -fill x
2706 # Completeness Attributes
2708 pack $w.top.completeness -pady 6 -padx 6 -side top
2709 label $w.top.completeness.label -text "Completeness" -width 18
2711 pack $w.top.completeness.label $w.top.completeness.b -fill x
2714 bottom-buttons $w [list \
2715 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2716 {Cancel} [list destroy $w]] 0
2720 proc query-edit-index {queryNo} {
2724 set i [lindex [$w.top.index.list curselection] 0]
2728 set attr [lindex $queryInfoTmp $i]
2729 dputs "Editing no $i $attr"
2730 index-setup $attr $queryNo $i
2733 proc query-delete-index {queryNo} {
2735 global queryButtonsTmp
2738 set i [lindex [$w.top.index.list curselection] 0]
2742 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2743 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2744 $w.top.index.list delete $i
2747 proc query-setup {queryNo} {
2753 global queryButtonsTmp
2755 global queryIndexTmp
2758 set queryName [lindex $queryTypes $queryNo]
2759 set queryInfoTmp [lindex $queryInfo $queryNo]
2760 set queryButtonsTmp [lindex $queryButtons $queryNo]
2765 wm title $w "Query setup $queryName"
2769 frame $w.top.lines -relief ridge -border 2
2771 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2775 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2777 button $w.top.lines.add -text "Add" \
2778 -command [list query-add-line $queryNo]
2779 button $w.top.lines.del -text "Remove" \
2780 -command [list query-del-line $queryNo]
2782 pack $w.top.lines.del -fill x -side bottom
2783 pack $w.top.lines.add -fill x -pady 10 -side bottom
2787 frame $w.top.index -relief ridge -border 2
2788 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2790 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2791 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2792 -command [list $w.top.index.list yview]
2793 bind $w.top.index.list <Double-1> [list query-edit-index $queryNo]
2795 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2796 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2799 $w.top.index.list selection clear 0 end
2800 $w.top.index.list selection set 0 0
2802 $w.top.index.list select from 0
2803 $w.top.index.list select to 0
2806 foreach x $queryInfoTmp {
2807 $w.top.index.list insert end [lindex $x 0]
2811 bottom-buttons $w [list \
2812 Ok [list query-setup-action $queryNo] \
2813 Add [list query-add-index $queryNo] \
2814 Edit [list query-edit-index $queryNo] \
2815 Delete [list query-delete-index $queryNo] \
2816 Cancel [list destroy $w]] 0
2819 proc index-clear {} {
2820 global queryButtonsFind
2823 foreach b $queryButtonsFind {
2824 .lines.$i.e delete 0 end
2829 proc index-query {} {
2830 global queryButtonsFind
2831 global queryInfoFind
2836 foreach b $queryButtonsFind {
2837 set term [string trim [.lines.$i.e get]]
2839 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
2842 set len [string length $term]
2846 if {[string index $term 0] == ">"} {
2847 if {[string index $term 1] == "=" } {
2848 set term [string trim [string range $term 2 $len]]
2851 set term [string trim [string range $term 1 $len]]
2854 } elseif {[string index $term 0] == "<"} {
2855 if {[string index $term 1] == "=" } {
2856 set term [string trim [string range $term 2 $len]]
2858 } elseif {[string index $term 1] == ">"} {
2859 set term [string trim [string range $term 2 $len]]
2862 set term [string trim [string range $term 1 $len]]
2867 set len [string length $term]
2871 if {[string index $term $len] == "?"} {
2873 set term [string range $term 0 [expr $len - 1]]
2875 if {[string index $term 0] == "?"} {
2877 set term [string range $term 1 end]
2879 set term "\{${term}\}"
2880 if {$right && $left} {
2881 set term "@attr 5=3 ${term}"
2883 set term "@attr 5=1 ${term}"
2885 set term "@attr 5=2 ${term}"
2887 if {$relation != ""} {
2888 set term "@attr 2=${relation} ${term}"
2891 set term "@attr $a ${term}"
2894 set qs "@and ${qs} ${term}"
2905 proc index-focus-in {w i} {
2906 global curIndexEntry
2909 $w.$i configure -background red
2911 set curIndexEntry $i
2914 proc index-lines {w realOp buttonInfo queryInfo handle} {
2916 foreach b $buttonInfo {
2917 if {! [winfo exists $w.$i]} {
2919 frame $w.$i -border 0
2921 frame $w.$i -background white -border 1
2924 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
2927 if {! [winfo exists $w.$i.e]} {
2928 entry $w.$i.e -width 32 -relief sunken -border 1
2929 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
2930 bind $w.$i.e <FocusOut> [list $w.$i configure \
2932 pack $w.$i.l -side left
2933 pack $w.$i.e -side left -fill x -expand yes
2934 pack $w.$i -side top -fill x -padx 2 -pady 2
2936 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2937 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2939 bind $w.$i.e <Return> {search-request 0}
2942 pack $w.$i.l -side left
2943 pack $w.$i -side top -fill x -padx 2 -pady 2
2948 while {[winfo exists $w.$j]} {
2960 bind $w.$j.e <Tab> "focus $w.$k.e"
2966 bind $w.$i.e <Tab> "focus $w.0.e"
2972 proc search-fields {w buttondefs} {
2974 foreach buttondef $buttondefs {
2975 frame $w.$i -background white
2977 listbutton $w.$i.l 0 $buttondef
2978 entry $w.$i.e -width 32 -relief sunken
2980 pack $w.$i.l -side left
2981 pack $w.$i.e -side left -fill x -expand yes
2983 pack $w.$i -side top -fill x -padx 2 -pady 2
2985 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2986 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2994 bind $w.$j.e <Tab> "focus $w.$k.e \n
2995 $w.$k configure -background red \n
2996 $w.$j configure -background white"
2999 bind $w.$i.e <Tab> "focus $w.0.e \n
3000 $w.0 configure -background red \n
3001 $w.$i configure -background white"
3003 $w.0 configure -background red
3006 if {[info exists windowGeometry(.)]} {
3007 set g $windowGeometry(.)
3015 frame .top -border 1 -relief raised
3016 frame .lines -border 1 -relief raised
3017 frame .mid -border 1 -relief raised
3018 frame .data -border 1 -relief raised
3019 frame .bot -border 1 -relief raised
3020 pack .top .lines .mid -side top -fill x
3021 pack .data -side top -fill both -expand yes
3024 menubutton .top.file -text "File" -menu .top.file.m
3026 .top.file.m add command -label "Save settings" -command {save-settings}
3027 .top.file.m add separator
3028 .top.file.m add command -label "Exit" -command {exit-action}
3030 menubutton .top.target -text "Target" -menu .top.target.m
3032 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
3033 .top.target.m add command -label "Disconnect" -command {close-target}
3034 .top.target.m add command -label "About" -command {about-target}
3035 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
3036 .top.target.m add command -label "Setup new" -command {define-target-dialog}
3037 .top.target.m add separator
3038 set-target-hotlist 0
3040 configure-disable-e .top.target.m 1
3041 configure-disable-e .top.target.m 2
3043 menu .top.target.m.clist
3044 menu .top.target.m.slist
3047 menubutton .top.service -text "Service" -menu .top.service.m
3049 .top.service.m add command -label "Database" -command {database-select}
3050 .top.service.m add cascade -label "Present" -menu .top.service.m.present
3051 menu .top.service.m.present
3052 .top.service.m.present add command -label "10 More" \
3053 -command [list present-more 10]
3054 .top.service.m.present add command -label "All" \
3055 -command [list present-more {}]
3056 .top.service.m add command -label "Search" -command {search-request 0}
3057 .top.service.m add command -label "Scan" -command {scan-request}
3059 .top.service configure -state disabled
3061 menubutton .top.rset -text "Set" -menu .top.rset.m
3063 .top.rset.m add command -label "Load" -command {load-set}
3064 .top.rset.m add separator
3066 menubutton .top.options -text "Options" -menu .top.options.m
3068 .top.options.m add cascade -label "Query" -menu .top.options.m.query
3069 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
3070 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
3071 .top.options.m add cascade -label "Syntax" -menu .top.options.m.syntax
3072 .top.options.m add cascade -label "Elements" -menu .top.options.m.elements
3074 menu .top.options.m.query
3075 .top.options.m.query add cascade -label "Select" \
3076 -menu .top.options.m.query.clist
3077 .top.options.m.query add cascade -label "Edit" \
3078 -menu .top.options.m.query.slist
3079 .top.options.m.query add command -label "New" \
3080 -command {query-new}
3081 .top.options.m.query add cascade -label "Delete" \
3082 -menu .top.options.m.query.dlist
3084 menu .top.options.m.query.slist
3085 menu .top.options.m.query.clist
3086 menu .top.options.m.query.dlist
3089 menu .top.options.m.formats
3091 foreach f $displayFormats {
3092 .top.options.m.formats add radiobutton -label $f -value $i \
3093 -command [list set-display-format $i] -variable displayFormat
3097 menu .top.options.m.wrap
3098 .top.options.m.wrap add radiobutton -label "Character" \
3099 -value char -variable textWrap -command {set-wrap char}
3100 .top.options.m.wrap add radiobutton -label "Word" \
3101 -value word -variable textWrap -command {set-wrap word}
3102 .top.options.m.wrap add radiobutton -label "None" \
3103 -value none -variable textWrap -command {set-wrap none}
3105 menu .top.options.m.syntax
3106 .top.options.m.syntax add radiobutton -label "None" \
3107 -value None -variable recordSyntax
3108 .top.options.m.syntax add separator
3109 .top.options.m.syntax add radiobutton -label "USMARC" \
3110 -value USMARC -variable recordSyntax
3111 .top.options.m.syntax add radiobutton -label "UNIMARC" \
3112 -value UNIMARC -variable recordSyntax
3113 .top.options.m.syntax add radiobutton -label "UKMARC" \
3114 -value UKMARC -variable recordSyntax
3115 .top.options.m.syntax add radiobutton -label "DANMARC" \
3116 -value DANMARC -variable recordSyntax
3117 .top.options.m.syntax add radiobutton -label "FINMARC" \
3118 -value FINMARC -variable recordSyntax
3119 .top.options.m.syntax add radiobutton -label "NORMARC" \
3120 -value NORMARC -variable recordSyntax
3121 .top.options.m.syntax add radiobutton -label "PICAMARC" \
3122 -value PICAMARC -variable recordSyntax
3123 .top.options.m.syntax add separator
3124 .top.options.m.syntax add radiobutton -label "SUTRS" \
3125 -value SUTRS -variable recordSyntax
3126 .top.options.m.syntax add separator
3127 .top.options.m.syntax add radiobutton -label "GRS1" \
3128 -value GRS1 -variable recordSyntax
3130 menu .top.options.m.elements
3131 .top.options.m.elements add radiobutton -label "Unspecified" \
3132 -value None -variable elementSetNames
3133 .top.options.m.elements add radiobutton -label "Full" \
3134 -value F -variable elementSetNames
3135 .top.options.m.elements add radiobutton -label "Brief" \
3136 -value B -variable elementSetNames
3138 menubutton .top.help -text "Help" -menu .top.help.m
3141 .top.help.m add command -label "Help on help" \
3142 -command {tkerror "Help on help not available. Sorry"}
3143 .top.help.m add command -label "About" -command {about-origin}
3145 pack .top.file .top.target .top.service .top.rset .top.options -side left
3146 pack .top.help -side right
3148 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
3150 button .mid.search -text Search -command {search-request 0} \
3152 button .mid.scan -text Scan \
3153 -command scan-request -state disabled
3154 button .mid.present -text {Present} -command [list present-more 10] \
3157 button .mid.clear -text Clear -command index-clear
3158 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
3161 text .data.record -height 2 -width 20 -wrap none \
3162 -yscrollcommand [list .data.scroll set] -wrap $textWrap
3163 scrollbar .data.scroll -command [list .data.record yview]
3165 .data.record configure -takefocus 0
3166 .data.scroll configure -takefocus 0
3168 pack .data.scroll -side right -fill y
3169 pack .data.record -expand yes -fill both
3173 .data.record tag configure marc-tag -foreground blue
3174 .data.record tag configure marc-id -foreground red
3176 .data.record tag configure marc-tag -foreground black
3177 .data.record tag configure marc-id -foreground black
3179 .data.record tag configure marc-data -foreground black
3180 .data.record tag configure marc-head \
3181 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3182 -foreground brown -relief raised -borderwidth 1
3183 .data.record tag configure marc-small-head -foreground brown
3184 .data.record tag configure marc-pref \
3185 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3187 .data.record tag configure marc-text \
3188 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3190 .data.record tag configure marc-it \
3191 -font -Adobe-Times-Medium-I-Normal-*-140-* \
3194 button .bot.logo -bitmap @${libdir}/bitmaps/book1 -command cancel-operation
3196 .bot.logo configure -takefocus 0
3199 pack .bot.a -side left -fill x
3200 pack .bot.logo -side right -padx 2 -pady 2 -ipadx 1
3202 message .bot.a.target -text "" -aspect 1000 -border 1
3204 label .bot.a.status -text "Not connected" -width 15 -relief \
3205 sunken -anchor w -border 1
3206 label .bot.a.set -text "" -width 5 -relief \
3207 sunken -anchor w -border 1
3208 label .bot.a.message -text "" -width 15 -relief \
3209 sunken -anchor w -border 1
3211 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
3212 pack .bot.a.status .bot.a.set .bot.a.message \
3213 -side left -padx 2 -pady 2 -ipadx 1 -ipady 1
3215 if {[catch {ir z39}]} {
3216 set e [info sharedlibextension]
3217 puts -nonewline "Loading irtcl$e ..."