1 # IR toolkit for tcl/tk
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
7 # Revision 1.75 1995-10-17 14:18:05 adam
8 # Minor changes in presentation formats.
10 # Revision 1.74 1995/10/17 12:18:57 adam
11 # Bug fix: when target connection closed, the connection was not
12 # properly reestablished.
14 # Revision 1.73 1995/10/17 10:58:06 adam
15 # More work on presentation formats.
17 # Revision 1.72 1995/10/16 17:00:52 adam
18 # New setting: elementSetNames.
19 # Various client improvements. Medium presentation format looks better.
21 # Revision 1.71 1995/10/13 15:35:27 adam
22 # Relational operators may be used in search entries - changes
23 # in proc index-query.
25 # Revision 1.70 1995/10/12 14:46:52 adam
26 # Better record popup windows. Next/prev buttons in popup record windows.
27 # The record position in the raw format is much more visible.
29 # Revision 1.69 1995/09/21 13:42:54 adam
32 # Revision 1.68 1995/09/21 13:11:49 adam
33 # Support of dynamic loading.
34 # Test script uses load command if necessary.
36 # Revision 1.67 1995/09/20 14:35:19 adam
39 # Revision 1.66 1995/08/29 15:30:13 adam
40 # Work on GRS records.
42 # Revision 1.65 1995/08/24 15:39:09 adam
45 # Revision 1.64 1995/08/24 15:33:02 adam
48 # Revision 1.63 1995/08/04 13:20:48 adam
49 # Buttons at the bottom are slightly smaller.
51 # Revision 1.62 1995/08/04 11:32:37 adam
52 # More work on output queue. Memory related routines moved
55 # Revision 1.61 1995/07/20 08:09:39 adam
56 # client.tcl: Targets removed from hotTargets list when targets
57 # are removed/modified.
58 # ir-tcl.c: More work on triggerResourceControl.
60 # Revision 1.60 1995/06/30 16:30:19 adam
63 # Revision 1.59 1995/06/29 14:06:25 adam
64 # Another bug in install fixed. Configure searches for more versions of yaz.
66 # Revision 1.58 1995/06/29 12:34:06 adam
67 # IrTcl now works with both tk4.0b4/tcl7.4b4 and tk3.6/tcl7.3
69 # Revision 1.57 1995/06/29 09:20:30 adam
70 # Target entries in cascade menus are sorted.
72 # Revision 1.56 1995/06/27 19:03:48 adam
73 # Bug fix in do_present in ir-tcl.c: p->set_child member weren't set.
74 # nextResultSetPosition used instead of setOffset.
76 # Revision 1.55 1995/06/27 17:10:37 adam
77 # Bug fix: install procedure didn't work on some systems.
78 # Error turned up when clientrc.tcl was't present.
80 # Revision 1.54 1995/06/27 14:41:03 adam
81 # Bug fix in search-response. Didn't always observe non-surrogate diagnostics.
83 # Revision 1.53 1995/06/26 12:40:09 adam
84 # Client defines its own tkerror.
85 # User may specify 'no preferredRecordSyntax'.
87 # Revision 1.52 1995/06/22 13:14:59 adam
88 # Feature: SUTRS. Setting getSutrs implemented.
89 # Work on display formats.
90 # Preferred record syntax can be set by the user.
92 # Revision 1.51 1995/06/21 11:11:00 adam
93 # Bug fix: libdir undefined in about-origin.
95 # Revision 1.50 1995/06/21 11:04:48 adam
96 # Uses GNU autoconf 2.3.
97 # Install procedure implemented.
98 # boook bitmaps moved to sub directory bitmaps.
100 # Revision 1.49 1995/06/20 14:16:42 adam
101 # More work on cancel mechanism.
103 # Revision 1.48 1995/06/20 08:07:23 adam
104 # New setting: failInfo.
105 # Working on better cancel mechanism.
107 # Revision 1.47 1995/06/19 14:05:29 adam
108 # Bug fix: asked for SUTRS.
110 # Revision 1.46 1995/06/19 13:06:06 adam
111 # New define: IR_TCL_VERSION.
113 # Revision 1.45 1995/06/19 08:08:44 adam
114 # client.tcl: hotTargets now contain both database and target name.
115 # ir-tcl.c: setting protocol edited. Errors in callbacks are logged
116 # by logf(LOG_WARN, ...) calls.
118 # Revision 1.44 1995/06/16 14:55:18 adam
119 # Book logo mirrored.
121 # Revision 1.43 1995/06/16 14:41:05 adam
122 # Scan line entries can be copied to a search entry.
124 # Revision 1.42 1995/06/16 12:28:13 adam
125 # Implemented preferredRecordSyntax.
126 # Minor changes in diagnostic handling.
127 # Record list deleted when connection closes.
129 # Revision 1.41 1995/06/14 15:07:59 adam
130 # Bug fix in cascade-target-list. Uses yaz-version.h.
132 # Revision 1.40 1995/06/14 13:37:17 adam
133 # Setting recordType implemented.
134 # Setting implementationVersion implemented.
135 # Settings implementationId / implementationName edited.
137 # Revision 1.39 1995/06/14 12:16:22 adam
138 # hotTargets, textWrap and displayFormat saved in clientg.tcl.
140 # Revision 1.38 1995/06/14 07:22:45 adam
141 # Target definitions can be deleted.
142 # Listbox used in the query definition dialog.
144 # Revision 1.37 1995/06/13 14:37:59 adam
145 # Work on query setup.
146 # Better about origin/target.
147 # Better presentation formats.
149 # Revision 1.36 1995/06/13 07:42:14 adam
150 # Bindings removed from text widgets.
152 # Revision 1.35 1995/06/12 15:17:31 adam
153 # Text widget used in main window (instead of listbox) to support
154 # better presentation formats.
156 # Revision 1.34 1995/06/12 07:59:07 adam
157 # More work on geometry handling.
159 # Revision 1.33 1995/06/09 11:17:35 adam
160 # Start work on geometry management.
162 # Revision 1.32 1995/06/07 09:16:37 adam
163 # New presentation format.
165 # Revision 1.31 1995/06/06 16:31:09 adam
166 # Bug fix: target names couldn't contain blanks.
169 # Revision 1.30 1995/06/06 11:35:41 adam
170 # Work on scan. Display of old sets.
172 # Revision 1.29 1995/06/05 14:11:18 adam
173 # Bug fix in present-more.
175 # Revision 1.28 1995/06/02 14:52:13 adam
176 # Minor changes really.
178 # Revision 1.27 1995/06/02 14:29:42 adam
179 # Work on scan interface - up/down buttons.
181 # Revision 1.26 1995/06/01 16:36:46 adam
182 # About buttons. Minor bug fixes.
184 # Revision 1.25 1995/05/31 13:09:57 adam
185 # Client searches/presents may be interrupted.
186 # New moving book-logo.
188 # Revision 1.24 1995/05/31 08:36:24 adam
189 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
190 # New method: referenceId. More work on scan.
192 # Revision 1.23 1995/05/29 10:33:41 adam
193 # README and rename of startup script.
195 # Revision 1.22 1995/05/26 11:44:09 adam
196 # Bugs fixed. More work on MARC utilities and queries. Test
197 # client is up-to-date again.
199 # Revision 1.21 1995/05/11 15:34:46 adam
200 # Scan request changed a bit. This version works with RLG.
202 # Revision 1.20 1995/04/21 16:31:57 adam
203 # New radiobutton: protocol (z39v2/SR).
205 # Revision 1.19 1995/04/18 16:11:50 adam
206 # First version of graphical Scan. Some work on query-by-form.
208 # Revision 1.18 1995/04/10 10:50:22 adam
209 # Result-set name defaults to suffix of ir-set name.
210 # Started working on scan. Not finished at this point.
212 # Revision 1.17 1995/03/31 09:34:57 adam
213 # Search-button disabled when there is no connection.
215 # Revision 1.16 1995/03/31 08:56:36 adam
216 # New button "Search".
218 # Revision 1.15 1995/03/28 12:45:22 adam
219 # New ir method failback: called on disconnect/protocol error.
220 # New ir set/get method: protocol: SR / Z3950.
221 # Simple popup and disconnect when failback is invoked.
223 # Revision 1.14 1995/03/22 16:07:55 adam
226 # Revision 1.13 1995/03/21 17:27:26 adam
227 # Short-hand keys in setup.
229 # Revision 1.12 1995/03/21 13:41:03 adam
230 # Comstack cs_create not used too often. Non-blocking connect.
232 # Revision 1.11 1995/03/21 10:39:06 adam
233 # Diagnostic error message displayed with tkerror.
235 # Revision 1.10 1995/03/20 15:24:06 adam
236 # Diagnostic records saved on searchResponse.
238 # Revision 1.9 1995/03/17 18:26:16 adam
239 # Non-blocking i/o used now. Database names popup as cascade items.
241 # Revision 1.8 1995/03/17 15:45:00 adam
242 # Improved target/database setup.
244 # Revision 1.7 1995/03/16 17:54:03 adam
245 # Minor changes really.
247 # Revision 1.6 1995/03/15 19:10:20 adam
248 # Database setup in protocol-setup (rather target setup).
250 # Revision 1.5 1995/03/15 13:59:23 adam
253 # Revision 1.4 1995/03/14 17:32:29 adam
254 # Presentation of full Marc record in popup window.
256 # Revision 1.3 1995/03/12 19:31:52 adam
257 # Pattern matching implemented when retrieving MARC records. More
258 # diagnostic functions.
260 # Revision 1.2 1995/03/10 18:00:15 adam
261 # Actual presentation in line-by-line format. RPN query support.
263 # Revision 1.1 1995/03/09 16:15:07 adam
264 # First presentRequest attempts. Hot-target list.
268 if {$tk_version == "3.6"} {
279 proc configure-enable-e {w n} {
281 $w entryconfigure $n -state normal
283 proc configure-disable-e {w n} {
285 $w entryconfigure $n -state disabled
287 set noFocus [list -takefocus 0]
289 proc configure-enable-e {w n} {
292 proc configure-disable-e {w n} {
299 if {[tk colormodel .] == "color"} {
309 if {[file readable bitmaps/book2]} {
312 if {! [file readable ${libdir}/bitmaps/book2]} {
313 puts "Cannot locate system files in ${libdir}. You must either run this"
314 puts "program from the source directory root of ir-tcl or you must assure"
315 puts "that it is installed - normally in /usr/local/lib/irtcl"
323 set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} Z39 1}
325 set settingsChanged 0
333 set recordSyntax None
334 set elementSetNames None
337 set queryTypes {Simple}
338 set queryButtons { { {I 0} {I 1} {I 2} } }
339 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
340 {Subject {1=21}} {Any {1=1016}} } }
349 if {[winfo exists $w]} {
358 label $w.top.b -bitmap error
359 message $w.top.t -aspect 300 -text "Error: $err" \
360 -font -Adobe-Helvetica-Bold-R-Normal-*-180-*
361 pack $w.top.b $w.top.t -side left -padx 10 -pady 10
363 bottom-buttons $w [list {Close} [list destroy $w]] 1
366 proc read-formats {} {
367 global displayFormats
369 if {[catch {set formats [glob -nocomplain ${libdir}/formats/*.tcl]}]} {
370 set formats ./formats/raw.tcl
373 if {[file readable $f]} {
375 set l [string length $f]
376 set f [string range $f [string length "${libdir}/formats/"] \
378 lappend displayFormats $f
387 .data.record configure -wrap $m
394 proc set-display-format {f} {
404 .bot.a.status configure -text "Reformatting"
407 add-title-lines -1 10000 1
410 proc initBindings {} {
413 bind $w <Double-1> {}
414 bind $w <Triple-1> {}
415 bind $w <B1-Motion> {}
417 bind $w <Shift-B1-Motion> {}
419 bind $w <B2-Motion> {}
420 bind $w <Any-KeyPress> {}
422 bind $w <BackSpace> {}
424 bind $w <Control-h> {}
425 bind $w <Control-d> {}
426 bind $w <Control-v> {}
429 bind $w <B1-Motion> {}
430 bind $w <Shift-B1-Motion> {}
435 proc post-menu {wbutton wmenu} {
438 $wmenu post [winfo rootx $wbutton] \
439 [expr [winfo rooty $wbutton]+[winfo height $wbutton]]
444 global windowGeometry
445 set windowGeometry($w) [wm geometry $w]
448 global windowGeometry
451 if {[info exists windowGeometry($w)]} {
452 set g $windowGeometry($w)
457 bind $w <Destroy> [list destroyGW $w]
460 if {[file readable "clientrc.tcl"]} {
461 source "clientrc.tcl"
463 if {[file readable "${libdir}/clientrc.tcl"]} {
464 source "${libdir}/clientrc.tcl"
468 if {[file readable "~/.clientrc.tcl"]} {
469 source "~/.clientrc.tcl"
472 set queryButtonsFind [lindex $queryButtons 0]
473 set queryInfoFind [lindex $queryInfo 0]
475 proc top-down-window {w} {
476 frame $w.top -relief raised -border 1
477 frame $w.bot -relief raised -border 1
479 pack $w.top -side top -fill both -expand yes
480 pack $w.bot -fill both
483 proc top-down-ok-cancel {w ok-action g} {
484 frame $w.bot.left -relief sunken -border 1
485 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 1 -pady 1
486 button $w.bot.left.ok -width 4 -text {Ok} \
487 -command ${ok-action}
488 pack $w.bot.left.ok -expand yes -ipadx 1 -ipady 1 -padx 2 -pady 2
489 button $w.bot.cancel -width 5 -text {Cancel} \
490 -command [list destroy $w]
491 pack $w.bot.cancel -side left -expand yes
499 proc bottom-buttons {w buttonList g} {
501 set l [llength $buttonList]
503 frame $w.bot.$i -relief sunken -border 1
504 pack $w.bot.$i -side left -expand yes -padx 2 -pady 2
505 button $w.bot.$i.ok -text [lindex $buttonList $i] \
506 -command [lindex $buttonList [expr $i+1]]
507 pack $w.bot.$i.ok -expand yes -padx 2 -pady 2 -side left
511 button $w.bot.$i -text [lindex $buttonList $i] \
512 -command [lindex $buttonList [expr $i+1]]
513 pack $w.bot.$i -expand yes -padx 2 -pady 2 -side left
523 proc cancel-operation {} {
531 show-status Cancel 0 1
535 proc show-target {target base} {
539 .bot.a.target configure -text ""
543 .bot.a.target configure -text "$target"
545 .bot.a.target configure -text "$target - $base"
549 proc show-logo {v1} {
558 .bot.logo configure -bitmap @${libdir}/bitmaps/book${v1}
559 after 140 [list show-logo $v1]
563 .bot.logo configure -bitmap @${libdir}/bitmaps/book1
572 proc show-status {status b sb} {
579 .bot.a.status configure -text "$status"
581 if {$busy == 0} {set busy 1}
589 .top.service configure -state normal
590 .mid.search configure -state normal
592 .mid.scan configure -state normal
595 configure-disable-e .top.service.m 1
596 } elseif {[z39.$setNo nextResultSetPosition] > 0 &&
597 [z39.$setNo nextResultSetPosition] <= [z39.$setNo resultCount]} {
598 configure-enable-e .top.service.m 1
599 .mid.present configure -state normal
601 configure-disable-e .top.service.m 1
602 .mid.present configure -state disabled
604 if {[winfo exists .scan-window]} {
605 .scan-window.bot.2 configure -state normal
606 .scan-window.bot.4 configure -state normal
609 .top.service configure -state disabled
610 .mid.search configure -state disabled
611 .mid.scan configure -state disabled
612 .mid.present configure -state disabled
614 if {[winfo exists .scan-window]} {
615 .scan-window.bot.2 configure -state disabled
616 .scan-window.bot.4 configure -state disabled
621 proc show-message {msg} {
622 .bot.a.message configure -text "$msg"
625 proc insertWithTags {w text args} {
626 set start [$w index insert]
627 $w insert insert $text
628 foreach tag [$w tag names $start] {
629 $w tag remove $tag $start insert
632 $w tag add $i $start insert
636 proc popup-license {} {
641 wm title $w "License"
647 text $w.top.t -width 80 -height 10 -wrap word \
648 -yscrollcommand [list $w.top.s set]
649 scrollbar $w.top.s -command [list $w.top.t yview]
651 pack $w.top.s -side right -fill y
652 pack $w.top.t -expand yes -fill both
654 if {[file readable "${libdir}/LICENSE"]} {
655 set f [open "${libdir}/LICENSE" r]
656 while {[gets $f buf] != -1} {
657 $w.top.t insert end $buf
658 $w.top.t insert end "\n"
662 bottom-buttons $w [list {Close} [list destroy $w]] 1
665 proc about-target {} {
666 set w .about-target-w
671 wm title $w "About target"
675 frame $w.top.a -relief ridge -border 2
676 frame $w.top.p -relief ridge -border 2
678 pack $w.top.a $w.top.p -side top -fill x
680 label $w.top.a.about -text "About"
681 label $w.top.a.irtcl -text $hostid \
682 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
683 pack $w.top.a.about $w.top.a.irtcl -side top
685 set i [z39 targetImplementationName]
686 label $w.top.p.in -text "Implementation name: $i"
687 set i [z39 targetImplementationId]
688 label $w.top.p.ii -text "Implementation id: $i"
689 set i [z39 targetImplementationVersion]
690 label $w.top.p.iv -text "Implementation version: $i"
692 label $w.top.p.op -text "Protocol options: $i"
694 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
696 bottom-buttons $w [list {Close} [list destroy $w]] 1
699 proc about-origin-logo {n} {
701 set w .about-origin-w
702 if {![winfo exists $w]} {
709 $w.top.a.logo configure -bitmap @${libdir}/bitmaps/book$n
710 after 140 [list about-origin-logo $n]
713 proc about-origin {} {
714 set w .about-origin-w
718 if {[winfo exists $w]} {
723 wm title $w "About IrTcl"
727 frame $w.top.a -relief ridge -border 2
728 frame $w.top.p -relief ridge -border 2
730 pack $w.top.a $w.top.p -side top -fill x
732 label $w.top.a.irtcl -text "IrTcl" \
733 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
734 label $w.top.a.logo -bitmap @${libdir}/bitmaps/book1
735 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
738 catch {set i [z39 implementationName]}
739 label $w.top.p.in -text "Implementation name: $i"
740 catch {set i [z39 implementationId]}
741 label $w.top.p.ii -text "Implementation id: $i"
742 catch {set i [z39 implementationVersion]}
743 label $w.top.p.iv -text "Implementation version: $i"
745 label $w.top.p.tk -text "Tk version: $i"
747 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.tk -side top -anchor nw
750 bottom-buttons $w [list {Close} [list destroy $w] \
751 {License} [list popup-license]] 0
754 proc popup-marc {sno no b df} {
755 global displayFormats
758 if {[z39.$sno type $no] != "DB"} {
763 while {[winfo exists .full-marc$b]} {
769 if {![winfo exists $w]} {
774 frame $w.top -relief raised -border 1
775 frame $w.bot -relief raised -border 1
777 pack $w.top -side top -fill both -expand yes
778 pack $w.bot -fill both
780 text $w.top.record -width 60 -height 5 -wrap word \
781 -yscrollcommand [list $w.top.s set]
782 scrollbar $w.top.s -command [list $w.top.record yview]
786 $w.top.record tag configure marc-tag -foreground blue
787 $w.top.record tag configure marc-id -foreground red
789 $w.top.record tag configure marc-tag -foreground black
790 $w.top.record tag configure marc-id -foreground black
792 $w.top.record tag configure marc-data -foreground black
793 $w.top.record tag configure marc-head \
794 -font -Adobe-Times-Medium-R-Normal-*-180-* \
795 -background black -foreground white
797 $w.top.record tag configure marc-pref \
798 -font -Adobe-Times-Medium-R-Normal-*-180-* \
800 $w.top.record tag configure marc-text \
801 -font -Adobe-Times-Medium-R-Normal-*-180-* \
803 $w.top.record tag configure marc-it \
804 -font -Adobe-Times-Medium-I-Normal-*-180-* \
807 pack $w.top.s -side right -fill y
808 pack $w.top.record -expand yes -fill both
810 bottom-buttons $w [list \
811 {Close} [list destroy $w] \
815 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m \
817 menu $w.bot.formats.m
818 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 \
819 -padx 3 -pady 3 -side left
821 $w.bot.formats.m delete 0 last
824 foreach f $displayFormats {
825 $w.bot.formats.m add radiobutton -label $f \
826 -variable popupMarcdf -value $i \
827 -command [list popup-marc $sno $no $b 0]
830 $w.top.record delete 0.0 end
831 set recordType [z39.$sno recordType $no]
832 wm title $w "$recordType record #$no"
834 $w.bot.2 configure -command \
835 [list popup-marc $sno [expr $no-1] $b $df]
836 $w.bot.4 configure -command \
837 [list popup-marc $sno [expr $no+1] $b $df]
839 $w.bot.2 configure -state disabled
841 $w.bot.2 configure -state normal
843 if {[z39.$sno type [expr $no+1]] != "DB"} {
844 $w.bot.4 configure -state disabled
846 $w.bot.4 configure -state normal
848 $w.bot.6 configure -command [list popup-marc $sno $no -1 0]
849 set ffunc [lindex $displayFormats $df]
850 set ffunc "display-$ffunc"
852 $ffunc $sno $no $w.top.record 0
855 proc update-target-hotlist {target base} {
858 set olen [llength $hotTargets]
860 foreach e $hotTargets {
861 if {$target == [lindex $e 0] && $base == [lindex $e 1]} {
862 set hotTargets [lreplace $hotTargets $i $i]
867 set hotTargets [linsert $hotTargets 0 [list $target $base]]
868 set-target-hotlist $olen
871 proc delete-target-hotlist {target} {
874 set olen [llength $hotTargets]
876 foreach e $hotTargets {
877 if {$target == [lindex $e 0]} {
878 set hotTargets [lreplace $hotTargets $i $i]
882 set-target-hotlist $olen
885 proc set-target-hotlist {olen} {
890 .top.target.m delete 7 [expr 7+$olen]
892 .top.target.m delete 6 [expr 6+$olen]
896 foreach e $hotTargets {
897 set target [lindex $e 0]
898 set base [lindex $e 1]
900 .top.target.m add command -label "$i $target" -command \
901 [list reopen-target $target {}]
903 .top.target.m add command -label "$i $target - $base" -command \
904 [list reopen-target $target $base]
913 proc reopen-target {target base} {
915 open-target $target $base
916 update-target-hotlist $target $base
919 proc define-target-action {} {
922 set target [.target-define.top.target.entry get]
926 foreach n [array names profile] {
932 set seq [lindex $profile(Default) 12]
934 set profile($target) $profile(Default)
935 set profile(Default) [lreplace $profile(Default) 12 12 [incr seq]]
937 protocol-setup $target
938 destroy .target-define
941 proc fail-response {target} {
942 set c [lindex [z39 failInfo] 0]
943 set m [lindex [z39 failInfo] 1]
948 proc connect-response {target base} {
949 dputs "connect-response"
950 show-target $target $base
954 proc open-target {target base} {
959 z39 comstack [lindex $profile($target) 6]
960 z39 protocol [lindex $profile($target) 11]
961 z39 idAuthentication [lindex $profile($target) 3]
962 z39 maximumRecordSize [lindex $profile($target) 4]
963 z39 preferredMessageSize [lindex $profile($target) 5]
964 dputs "maximumRecordSize="
965 dputs [z39 maximumRecordSize]
966 dputs "preferredMessageSize="
967 dputs [z39 preferredMessageSize]
968 show-status Connecting 1 0
970 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
972 z39 databaseNames $base
974 z39 failback [list fail-response $target]
975 z39 callback [list connect-response $target $base]
978 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
981 tkerror $errorMessage
982 show-status "Not connected" 0 {}
986 configure-disable-e .top.target.m 0
987 configure-enable-e .top.target.m 1
988 configure-enable-e .top.target.m 2
991 proc close-target {} {
1000 .bot.a.set configure -text ""
1004 show-status {Not connected} 0 0
1007 configure-disable-e .top.target.m 1
1008 configure-disable-e .top.target.m 2
1010 .top.rset.m delete 2 last
1012 .top.rset.m delete 1 last
1014 .top.rset.m add separator
1015 configure-enable-e .top.target.m 0
1018 proc load-set-action {} {
1022 ir-set z39.$setNoLast z39
1024 set fname [.load-set.top.filename.entry get]
1027 show-status Loading 1 {}
1029 z39.$setNoLast loadFile $fname
1031 set no [z39.$setNoLast numberOfRecordsReturned]
1032 add-title-lines $setNoLast $no 1
1034 set l [format "%-4d %7d" $setNoLast $no]
1035 .top.rset.m add command -label $l \
1036 -command [list add-title-lines $setNoLast 10000 1]
1037 show-status Ready 0 {}
1043 set oldFocus [focus]
1047 frame $w.top.filename
1048 pack $w.top.filename -side top -anchor e -pady 2
1050 entry-fields $w.top {filename} \
1052 {load-set-action} {destroy .load-set}
1054 top-down-ok-cancel $w {load-set-action} 1
1058 proc init-request {} {
1065 z39 callback {init-response}
1066 show-status Initializing 1 {}
1067 set err [catch {z39 init} errorMessage]
1069 tkerror $errorMessage
1070 show-status Ready 0 {}
1074 proc init-response {} {
1078 dputs {init-reponse}
1083 if {![z39 initResult]} {
1084 show-status Ready 0 1
1085 set u [z39 userInformationField]
1087 tkerror "Connection rejected by target: $u"
1089 if {[lsearch [z39 options] scan] >= 0} {
1094 show-status Ready 0 1
1098 proc search-request {bflag} {
1107 global elementSetNames
1111 if {[z39 connect] == ""} {
1114 dputs "search-request"
1116 if {!$bflag && $busy} {
1117 dputs "busy: search-request ignored"
1122 show-status Searching 1 0
1123 set delayRequest {search-request 1}
1128 set query [index-query]
1133 set setNo $setNoLast
1134 ir-set z39.$setNo z39
1136 if {[lindex $profile($target) 10] == 1} {
1137 z39.$setNo setName $setNo
1138 dputs "setName=${setNo}"
1140 z39.$setNo setName Default
1141 dputs "setName=Default"
1143 if {[lindex $profile($target) 8] == 1} {
1144 z39.$setNo queryType rpn
1146 if {[lindex $profile($target) 9] == 1} {
1147 z39.$setNo queryType ccl
1151 if {$recordSyntax == "None" } {
1152 z39.$setNo preferredRecordSyntax {}
1154 z39.$setNo preferredRecordSyntax $recordSyntax
1156 if {$elementSetNames == "None" } {
1157 z39.$setNo elementSetNames {}
1159 z39.$setNo elementSetNames $elementSetNames
1161 z39 callback {search-response}
1162 z39.$setNo search $query
1163 show-status Searching 1 0
1166 proc scan-copy {y entry} {
1168 set no [$w.top.list nearest $y]
1170 .lines.$entry.e delete 0 end
1171 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
1174 proc scan-request {} {
1181 global curIndexEntry
1182 global queryButtonsFind
1183 global queryInfoFind
1187 dputs "scan-request"
1190 show-status Scanning 1 0
1191 set delayRequest scan-request
1200 set b [lindex $queryButtonsFind $curIndexEntry]
1202 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
1203 set attr "@attr $a $attr"
1205 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
1206 ir-scan z39.scan z39
1208 if {![winfo exists $w]} {
1215 entry $w.top.entry -relief sunken
1216 pack $w.top.entry -fill x -padx 4 -pady 2
1217 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
1218 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
1220 scrollbar $w.top.scroll -orient vertical -border 1
1221 pack $w.top.list -side left -fill both -expand yes
1222 pack $w.top.scroll -side right -fill y
1223 $w.top.scroll config -command [list $w.top.list yview]
1225 bottom-buttons $w [list {Close} [list destroy $w] \
1226 {Up} [list scan-up $attr] \
1227 {Down} [list scan-down $attr]] 0
1228 bind $w.top.list <Up> [list scan-up $attr]
1229 bind $w.top.list <Down> [list scan-down $attr]
1232 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
1233 wm title $w "Scan $title"
1235 z39 callback [list scan-response $attr 0 35]
1236 z39.scan numberOfTermsRequested 5
1237 z39.scan preferredPositionInResponse 1
1238 z39.scan scan "${attr} 0"
1240 show-status Scanning 1 0
1243 proc scan-term-h {attr} {
1251 set nScanTerm [$w.top.entry get]
1252 if {$nScanTerm == $scanTerm} {
1255 set scanTerm $nScanTerm
1256 z39 callback [list scan-response $attr 0 35]
1257 z39.scan numberOfTermsRequested 5
1258 z39.scan preferredPositionInResponse 1
1259 dputs "${attr} \{${scanTerm}\}"
1260 if {$scanTerm == ""} {
1261 z39.scan scan "${attr} 0"
1263 z39.scan scan "${attr} \{${scanTerm}\}"
1265 show-status Scanning 1 0
1268 proc scan-response {attr start toget} {
1275 dputs "In scan-response"
1276 set m [z39.scan numberOfEntriesReturned]
1282 if {![winfo exists .scan-window]} {
1285 dputs "Handling cancel"
1286 if {$delayRequest != ""} {
1291 show-status Ready 0 1
1294 set nScanTerm [$w.top.entry get]
1295 if {$nScanTerm != $scanTerm} {
1296 z39 callback [list scan-response $attr 0 35]
1297 z39.scan numberOfTermsRequested 5
1298 z39.scan preferredPositionInResponse 1
1299 set scanTerm $nScanTerm
1300 dputs "${attr} \{${scanTerm}\}"
1301 if {$scanTerm == ""} {
1302 z39.scan scan "${attr} 0"
1304 z39.scan scan "${attr} \{${scanTerm}\}"
1306 show-status Scanning 1 0
1309 set status [z39.scan scanStatus]
1312 show-status Ready 0 1
1317 for {set i 0} {$i < $m} {incr i} {
1318 set term [lindex [z39.scan scanLine $i] 1]
1319 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1320 $w.top.list insert $i "$nostr $term"
1323 $w.top.list yview $scanView
1325 $w.top.list delete $start end
1326 for {set i 0} {$i < $m} {incr i} {
1327 set term [lindex [z39.scan scanLine $i] 1]
1328 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1329 $w.top.list insert end "$nostr $term"
1333 dputs "Handling cancel"
1335 if {$delayRequest != ""} {
1341 if {$toget > 0 && $m > 1 && $m < $toget} {
1342 set ntoget [expr $toget - $m + 1]
1343 dputs ntoget=$ntoget
1344 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1346 dputs "down continue: $q"
1348 z39.scan numberOfTermsRequested 10
1350 z39.scan numberOfTermsRequested $ntoget
1352 z39.scan preferredPositionInResponse 1
1353 dputs "${attr} \{$q\}"
1354 z39.scan scan "${attr} \{$q\}"
1357 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1358 set ntoget [expr - $toget - $m]
1359 dputs ntoget=$ntoget
1360 z39 callback [list scan-response $attr 0 -$ntoget]
1361 set q [string range [$w.top.list get 0] 8 end]
1362 dputs "up continue: $q"
1364 z39.scan numberOfTermsRequested 10
1365 z39.scan preferredPositionInResponse 11
1367 z39.scan numberOfTermsRequested $ntoget
1368 z39.scan preferredPositionInResponse [incr ntoget]
1370 dputs "${attr} \{$q\}"
1371 z39.scan scan "${attr} \{$q\}"
1374 show-status Ready 0 1
1377 proc scan-down {attr} {
1385 show-status {Scanning down} 1 0
1386 set delayRequest [list scan-down $attr]
1392 set scanView [expr $scanView + 5]
1393 set s [$w.top.list size]
1394 if {$scanView > $s} {
1395 z39 callback [list scan-response $attr [expr $s - 1] 25]
1396 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1398 z39.scan numberOfTermsRequested 10
1399 z39.scan preferredPositionInResponse 1
1400 show-status Scanning 1 0
1401 dputs "${attr} \{$q\}"
1402 z39.scan scan "${attr} \{$q\}"
1405 $w.top.list yview $scanView
1408 proc scan-up {attr} {
1416 show-status Scanning 1 0
1417 set delayRequest [list scan-up $attr]
1423 set scanView [expr $scanView - 5]
1424 if {$scanView < 0} {
1425 z39 callback [list scan-response $attr 0 -25]
1426 set q [string range [$w.top.list get 0] 8 end]
1428 z39.scan numberOfTermsRequested 10
1429 z39.scan preferredPositionInResponse 11
1430 show-status Scanning 1 0
1431 z39.scan scan "${attr} \{$q\}"
1434 $w.top.list yview $scanView
1437 proc search-response {} {
1445 dputs "In search-response"
1447 dputs "Handling cancel"
1449 if {$delayRequest != ""} {
1457 set setMax [z39.$setNo resultCount]
1458 show-status Ready 0 1
1459 set status [z39.$setNo responseStatus]
1460 if {[lindex $status 0] == "NSD"} {
1461 z39.$setNo nextResultSetPosition 0
1462 set code [lindex $status 1]
1463 set msg [lindex $status 2]
1464 set addinfo [lindex $status 3]
1465 tkerror "NSD$code: $msg: $addinfo"
1468 show-message "${setMax} hits"
1473 show-status Ready 0 1
1474 set l [format "%-4d %7d" $setNo $setMax]
1475 .top.rset.m add command -label $l \
1476 -command [list add-title-lines $setNo 10000 1]
1480 z39 callback {present-response}
1481 z39.$setNo present $setOffset 1
1482 show-status Retrieving 1 0
1485 proc present-more {number} {
1493 dputs "present-more"
1495 show-status Retrieving 1 0
1496 set delayRequest "present-more $number"
1502 dputs "setNo=$setNo"
1505 set setOffset [z39.$setNo nextResultSetPosition]
1506 dputs "setOffest=${setOffset}"
1507 dputs "setNo=${setNo}"
1508 set max [z39.$setNo resultCount]
1509 if {$max < $setOffset} {
1511 dputs "setOffset=$setOffset"
1512 show-status Ready 0 1
1515 if {$number == ""} {
1519 if {$setMax > $max} {
1523 z39 callback {present-response}
1525 set toGet [expr $setMax - $setOffset + 1]
1532 z39.$setNo present $setOffset $toGet
1533 show-status Retrieving 1 0
1536 proc init-title-lines {} {
1537 .data.record delete 0.0 end
1540 proc add-title-lines {setno no offset} {
1541 global displayFormats
1542 global displayFormat
1552 .bot.a.set configure -text $setno
1553 .data.record delete 0.0 end
1555 set ffunc [lindex $displayFormats $displayFormat]
1556 dputs "ffunc=$ffunc"
1557 set ffunc "display-$ffunc"
1558 for {set i 0} {$i < $no} {incr i} {
1559 set o [expr $i + $offset]
1560 set type [z39.$setno type $o]
1564 .data.record tag bind r$o <Any-Enter> {}
1565 .data.record tag bind r$o <Any-Leave> {}
1566 set insert0 [.data.record index insert]
1567 $ffunc $setno $o .data.record 1
1568 .data.record tag add r$o $insert0 insert
1569 .data.record tag bind r$o <1> \
1570 [list popup-marc $setno $o 0 0]
1574 show-status Ready 0 1
1578 proc present-response {} {
1585 dputs "In present-response"
1586 set no [z39.$setNo numberOfRecordsReturned]
1587 dputs "Returned $no records, setOffset $setOffset"
1588 add-title-lines $setNo $no $setOffset
1589 set setOffset [expr $setOffset + $no]
1591 dputs "Handling cancel"
1593 if {$delayRequest != ""} {
1598 set status [z39.$setNo responseStatus]
1599 if {[lindex $status 0] == "NSD"} {
1600 show-status Ready 0 1
1601 set code [lindex $status 1]
1602 set msg [lindex $status 2]
1603 set addinfo [lindex $status 3]
1604 tkerror "NSD$code: $msg: $addinfo"
1607 if {$no > 0 && $setOffset <= $setMax} {
1608 dputs "present-request from ${setOffset}"
1609 set toGet [expr $setMax - $setOffset + 1]
1613 z39.$setNo present $setOffset $toGet
1615 show-status Ready 0 1
1619 proc left-cursor {w} {
1620 set i [$w index insert]
1628 proc right-cursor {w} {
1629 set i [$w index insert]
1635 proc bind-fields {list returnAction escapeAction} {
1636 set max [expr [llength $list]-1]
1637 for {set i 0} {$i < $max} {incr i} {
1638 bind [lindex $list $i] <Return> $returnAction
1639 bind [lindex $list $i] <Escape> $escapeAction
1641 bind [lindex $list $i] <Tab> \
1642 [list focus [lindex $list [expr $i+1]]]
1643 bind [lindex $list $i] <Left> \
1644 [list left-cursor [lindex $list $i]]
1645 bind [lindex $list $i] <Right> \
1646 [list right-cursor [lindex $list $i]]
1649 bind [lindex $list $i] <Return> $returnAction
1650 bind [lindex $list $i] <Escape> $escapeAction
1652 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1653 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1654 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1656 focus [lindex $list 0]
1659 proc entry-fields {parent list tlist returnAction escapeAction} {
1662 foreach field $list {
1663 set label ${parent}.${field}.label
1664 set entry ${parent}.${field}.entry
1665 label $label -text [lindex $tlist $i] -anchor e
1666 entry $entry -width 32 -relief sunken
1667 pack $label -side left
1668 pack $entry -side right
1669 lappend alist $entry
1672 bind-fields $alist $returnAction $escapeAction
1675 proc define-target-dialog {} {
1676 set w .target-define
1682 pack $w.top.target \
1683 -side top -anchor e -pady 2
1684 entry-fields $w.top {target} \
1686 {define-target-action} {destroy .target-define}
1687 top-down-ok-cancel $w {define-target-action} 1
1690 proc protocol-setup-delete {target w} {
1692 global settingsChanged
1694 set a [alert "Are you sure you want to delete the target \
1695 definition $target ?"]
1698 unset profile($target)
1699 set settingsChanged 1
1701 delete-target-hotlist $target
1705 proc protocol-setup-action {target w} {
1708 global protocolRadioType
1709 global settingsChanged
1712 global ResultSetCheck
1715 set settingsChanged 1
1716 set len [$w.top.databases.list size]
1717 for {set i 0} {$i < $len} {incr i} {
1718 lappend b [$w.top.databases.list get $i]
1720 set profile($target) [list [$w.top.description.entry get] \
1721 [$w.top.host.entry get] \
1722 [$w.top.port.entry get] \
1723 [$w.top.idAuthentication.entry get] \
1724 [$w.top.maximumRecordSize.entry get] \
1725 [$w.top.preferredMessageSize.entry get] \
1731 $protocolRadioType \
1735 delete-target-hotlist $target
1736 dputs $profile($target)
1740 proc place-force {window parent} {
1741 set g [wm geometry $parent]
1743 set p1 [string first + $g]
1744 set p2 [string last + $g]
1746 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1747 set y [expr 60+[string range $g [expr $p2 +1] end]]
1748 wm geometry $window +${x}+${y}
1751 proc add-database-action {target w} {
1754 $w.top.databases.list insert end \
1755 [.database-select.top.database.entry get]
1756 destroy .database-select
1759 proc add-database {target wp} {
1762 set w .database-select
1764 set oldFocus [focus]
1770 frame $w.top.database
1772 pack $w.top.database -side top -anchor e -pady 2
1774 entry-fields $w.top {database} \
1775 {{Database to add:}} \
1776 [list add-database-action $target $wp] {destroy .database-select}
1778 top-down-ok-cancel $w [list add-database-action $target $wp] 1
1782 proc delete-database {target w} {
1786 foreach i [$w.top.databases.list curselection] {
1787 set b [$w.top.databases.list get $i]
1790 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1792 foreach i [lsort -decreasing \
1793 [$w.top.databases.list curselection]] {
1794 $w.top.databases.list delete $i
1799 proc protocol-setup {target} {
1802 global protocolRadioType
1805 global ResultSetCheck
1808 while {[winfo exists .setup-$b]} {
1815 wm title $w "Setup $target"
1819 if {$target == ""} {
1823 dputs $profile($target)
1825 frame $w.top.description
1828 frame $w.top.idAuthentication
1829 frame $w.top.maximumRecordSize
1830 frame $w.top.preferredMessageSize
1831 frame $w.top.cs-type -relief ridge -border 2
1832 frame $w.top.protocol -relief ridge -border 2
1833 frame $w.top.query -relief ridge -border 2
1834 frame $w.top.databases -relief ridge -border 2
1836 # Maximum/preferred/idAuth ...
1837 pack $w.top.description $w.top.host $w.top.port \
1838 $w.top.idAuthentication $w.top.maximumRecordSize \
1839 $w.top.preferredMessageSize -side top -anchor e -pady 2
1841 entry-fields $w.top {description host port idAuthentication \
1842 maximumRecordSize preferredMessageSize} \
1843 {{Description:} {Host:} {Port:} {Id Authentication:} \
1844 {Maximum Record Size:} {Preferred Message Size:}} \
1845 [list protocol-setup-action $target $w] [list destroy $w]
1847 foreach sub {description host port idAuthentication \
1848 maximumRecordSize preferredMessageSize} {
1850 bind $w.top.$sub.entry <Control-a> [list add-database $target $w]
1851 bind $w.top.$sub.entry <Control-d> [list delete-database $target $w]
1853 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1854 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1855 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1856 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1857 $w.top.maximumRecordSize.entry insert 0 [lindex $profile($target) 4]
1858 $w.top.preferredMessageSize.entry insert 0 [lindex $profile($target) 5]
1859 set csRadioType [lindex $profile($target) 6]
1860 set RPNCheck [lindex $profile($target) 8]
1861 set CCLCheck [lindex $profile($target) 9]
1862 set ResultSetCheck [lindex $profile($target) 10]
1863 set protocolRadioType [lindex $profile($target) 11]
1864 if {$protocolRadioType == ""} {
1865 set protocolRadioType Z39
1869 pack $w.top.databases -side left -pady 2 -padx 2 -expand yes -fill both
1871 label $w.top.databases.label -text "Databases"
1872 button $w.top.databases.add -text Add \
1873 -command [list add-database $target $w]
1874 button $w.top.databases.delete -text Delete \
1875 -command [list delete-database $target $w]
1877 listbox $w.top.databases.list -geometry 14x6 \
1878 -yscrollcommand "$w.top.databases.scroll set"
1880 listbox $w.top.databases.list -width 14 -height 5\
1881 -yscrollcommand "$w.top.databases.scroll set"
1883 scrollbar $w.top.databases.scroll -orient vertical -border 1
1884 pack $w.top.databases.label -side top -fill x \
1886 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1888 pack $w.top.databases.list -side left -fill both -expand yes \
1890 pack $w.top.databases.scroll -side right -fill y \
1892 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1894 foreach b [lindex $profile($target) 7] {
1895 $w.top.databases.list insert end $b
1899 pack $w.top.cs-type -pady 2 -padx 2 -side top -fill x
1901 label $w.top.cs-type.label -text "Transport"
1902 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1903 -variable csRadioType -value tcpip
1904 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1905 -variable csRadioType -value mosi
1907 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1908 -padx 2 -side top -fill x
1911 pack $w.top.protocol -pady 2 -padx 2 -side top -fill x
1913 label $w.top.protocol.label -text "Protocol"
1914 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1915 -variable protocolRadioType -value Z39
1916 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1917 -variable protocolRadioType -value SR
1919 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1920 -padx 2 -side top -fill x
1923 pack $w.top.query -pady 2 -padx 2 -side top -fill x
1925 label $w.top.query.label -text "Query support"
1926 checkbutton $w.top.query.c1 -text "RPN query" -anchor w -variable RPNCheck
1927 checkbutton $w.top.query.c2 -text "CCL query" -anchor w -variable CCLCheck
1928 checkbutton $w.top.query.c3 -text "Result sets" -anchor w -variable ResultSetCheck
1930 pack $w.top.query.label -side top
1931 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
1932 -padx 2 -side top -fill x
1935 bottom-buttons $w [list {Ok} [list protocol-setup-action $target $w] \
1936 {Delete} [list protocol-setup-delete $target $w] \
1937 {Cancel} [list destroy $w]] 0
1940 proc database-select-action {} {
1941 set w .database-select.top
1943 foreach indx [$w.databases.list curselection] {
1944 lappend b [$w.databases.list get $indx]
1947 z39 databaseNames $b
1949 destroy .database-select
1952 proc database-select {} {
1953 set w .database-select
1958 set oldFocus [focus]
1963 frame $w.top.databases -relief ridge -border 2
1965 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
1967 label $w.top.databases.label -text "List"
1968 listbox $w.top.databases.list -width 20 -height 6 \
1969 -yscrollcommand "$w.top.databases.scroll set"
1970 scrollbar $w.top.databases.scroll -orient vertical -border 1
1971 pack $w.top.databases.label -side top -fill x \
1973 pack $w.top.databases.list -side left -fill both -expand yes \
1975 pack $w.top.databases.scroll -side right -fill y \
1977 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1979 foreach b [lindex $profile($hostid) 7] {
1980 $w.top.databases.list insert end $b
1982 top-down-ok-cancel $w {database-select-action} 1
1986 proc cascade-target-list {} {
1989 foreach sub [winfo children .top.target.m.clist] {
1992 .top.target.m.clist delete 0 last
1993 foreach n [lsort [array names profile]] {
1994 if {$n != "Default"} {
1995 set nl [lindex $profile($n) 12]
1996 if {[llength [lindex $profile($n) 7]] > 1} {
1997 .top.target.m.clist add cascade -label $n \
1998 -menu .top.target.m.clist.$nl
1999 menu .top.target.m.clist.$nl
2000 foreach b [lindex $profile($n) 7] {
2001 .top.target.m.clist.$nl add command -label $b \
2002 -command [list reopen-target $n $b]
2005 .top.target.m.clist add command -label $n \
2006 -command [list reopen-target $n {}]
2010 .top.target.m.slist delete 0 last
2011 foreach n [lsort [array names profile]] {
2012 if {$n != "Default"} {
2013 .top.target.m.slist add command -label $n \
2014 -command [list protocol-setup $n]
2019 proc query-select {i} {
2020 global queryButtonsFind
2021 global queryInfoFind
2025 set queryInfoFind [lindex $queryInfo $i]
2026 set queryButtonsFind [lindex $queryButtons $i]
2028 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2031 proc query-new-action {} {
2035 global settingsChanged
2037 set settingsChanged 1
2038 lappend queryTypes [.query-new.top.index.entry get]
2039 lappend queryButtons {}
2040 lappend queryInfo {}
2050 set oldFocus [focus]
2055 -side top -anchor e -pady 2
2056 entry-fields $w.top index \
2058 query-new-action {destroy .query-new}
2059 top-down-ok-cancel $w query-new-action 1
2063 proc query-delete-action {queryNo} {
2067 global settingsChanged
2069 set settingsChanged 1
2071 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
2072 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
2073 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
2074 destroy .query-delete
2078 proc query-delete {queryNo} {
2086 set n [lindex $queryTypes $queryNo]
2088 label $w.top.warning -bitmap warning
2089 message $w.top.quest -text "Are you sure you want to delete the \
2090 query type $n ?" -aspect 300
2091 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
2092 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
2093 {Cancel} [list destroy $w]] 1
2096 proc cascade-query-list {} {
2098 set w .top.options.m.query
2101 $w.slist delete 0 last
2102 foreach n $queryTypes {
2103 $w.slist add command -label $n -command [list query-setup $i]
2108 $w.clist delete 0 last
2109 foreach n $queryTypes {
2110 $w.clist add command -label $n -command [list query-select $i]
2114 $w.dlist delete 0 last
2115 foreach n $queryTypes {
2116 $w.dlist add command -label $n -command [list query-delete $i]
2121 proc save-geometry {} {
2122 global windowGeometry
2125 global displayFormat
2128 global elementSetNames
2130 set windowGeometry(.) [wm geometry .]
2132 if {[catch {set f [open ~/.clientrc.tcl w]}]} {
2135 puts $f "set hotTargets \{ $hotTargets \}"
2136 puts $f "set textWrap $textWrap"
2137 puts $f "set displayFormat $displayFormat"
2138 puts $f "set popupMarcdf $popupMarcdf"
2139 puts $f "set recordSyntax $recordSyntax"
2140 puts $f "set elementSetNames $elementSetNames"
2141 foreach n [array names windowGeometry] {
2142 puts -nonewline $f "set \{windowGeometry($n)\} \{"
2143 puts -nonewline $f $windowGeometry($n)
2149 proc save-settings {} {
2152 global settingsChanged
2157 if {![file writable "${libdir}/clientrc.tcl"]} {
2158 set a [alert "Cannot open ${libdir}/clientrc.tcl for writing. Do you \
2159 wish to save clientrc.tcl in the current directory instead?"]
2163 set f [open "clientrc.tcl" w]
2165 set f [open "${libdir}/clientrc.tcl" w]
2167 puts $f "# Setup file"
2169 foreach n [array names profile] {
2170 puts -nonewline $f "set \{profile($n)\} \{"
2171 puts -nonewline $f $profile($n)
2174 puts -nonewline $f "set queryTypes \{"
2175 puts -nonewline $f $queryTypes
2178 puts -nonewline $f "set queryButtons \{"
2179 puts -nonewline $f $queryButtons
2182 puts -nonewline $f "set queryInfo \{"
2183 puts -nonewline $f $queryInfo
2186 set settingsChanged 0
2195 set oldFocus [focus]
2199 label $w.top.warning -bitmap warning
2200 message $w.top.message -text $ask -aspect 300 \
2201 -font -Adobe-Times-Medium-R-Normal-*-180-*
2203 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
2206 top-down-ok-cancel $w {alert-action} 1
2211 proc alert-action {} {
2217 proc exit-action {} {
2218 global settingsChanged
2220 if {$settingsChanged} {
2221 set a [alert "you haven't saved your settings. Do you wish to save?"]
2230 proc listbuttonaction {w name h user i} {
2231 $w configure -text [lindex $name 0]
2232 $h [lindex $name 1] $user $i
2235 proc listbuttonx {button no names handle user} {
2236 if {[winfo exists $button]} {
2237 $button configure -text [lindex [lindex $names $no] 0]
2238 ${button}.m delete 0 last
2240 menubutton $button -text [lindex [lindex $names $no] 0] \
2241 -width 10 -menu ${button}.m -relief raised -border 1
2245 foreach name $names {
2246 ${button}.m add command -label [lindex $name 0] \
2247 -command [list listbuttonaction ${button} $name \
2253 proc listbutton {button no names} {
2254 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
2255 -relief raised -border 1
2257 foreach name $names {
2258 ${button}.m add command -label $name \
2259 -command [list ${button} configure -text $name]
2263 proc listbuttonv-action {button var names i} {
2266 set $var [lindex $names [expr $i+1]]
2267 $button configure -text [lindex $names $i]
2270 proc listbuttonv {button var names} {
2274 eval "set val $$var"
2275 set l [llength $names]
2276 for {set i 1} {$i < $l} {incr i 2} {
2277 if {$val == [lindex $names $i]} {
2279 set n [lindex $names $i]
2283 if {[winfo exists $button]} {
2284 $button configure -text $n
2287 menubutton $button -text $n -menu ${button}.m \
2288 -relief raised -border 1
2290 for {set i 0} {$i < $l} {incr i 2} {
2291 ${button}.m add command -label [lindex $names $i] \
2292 -command [list listbuttonv-action $button $var $names $i]
2296 proc query-add-index-action {queryNo} {
2300 global queryButtonsTmp
2302 set newI [.query-add-index.top.index.entry get]
2303 lappend queryInfoTmp [list $newI {}]
2304 $w.top.index.list insert end $newI
2305 destroy .query-add-index
2306 #destroy $w.top.lines
2307 #frame $w.top.lines -relief ridge -border 2
2308 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2309 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2312 proc query-add-line {queryNo} {
2316 global queryButtonsTmp
2318 lappend queryButtonsTmp {I 0}
2320 #destroy $w.top.lines
2321 #frame $w.top.lines -relief ridge -border 2
2322 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2323 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2326 proc query-del-line {queryNo} {
2330 global queryButtonsTmp
2332 set l [llength $queryButtonsTmp]
2337 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
2338 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2341 proc query-add-index {queryNo} {
2342 set w .query-add-index
2345 set oldFocus [focus]
2346 place-force $w .query-setup
2350 -side top -anchor e -pady 2
2351 entry-fields $w.top {index} \
2353 [list query-add-index-action $queryNo] [list destroy $w]
2354 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
2358 proc query-setup-action {queryNo} {
2361 global queryButtonsTmp
2363 global queryButtonsFind
2364 global queryInfoFind
2366 global settingsChanged
2368 set settingsChanged 1
2370 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
2372 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
2374 set queryInfoFind $queryInfoTmp
2375 set queryButtonsFind $queryButtonsTmp
2377 destroy .query-setup
2378 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2381 proc activate-e-index {value no i} {
2382 global queryButtonsTmp
2383 global queryIndexTmp
2385 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
2386 dputs $queryButtonsTmp
2387 set queryIndexTmp $i
2390 proc activate-index {value no i} {
2391 global queryButtonsFind
2393 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
2395 dputs "queryButtonsFind $queryButtonsFind"
2398 proc update-attr {} {
2400 listbuttonv $w.top.relation.b relationTmpValue\
2401 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
2402 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
2403 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
2404 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
2405 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
2406 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
2407 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
2408 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
2409 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
2410 {local-number} 107 {string} 108 {numeric string} 109}
2411 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2412 {Left} 2 {Left and right} 3 {No truncation} 100 \
2413 {Process #} 101 {Re-1} 102 {Re-2} 103}
2414 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2415 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2418 proc use-attr {init} {
2430 {BNB card number} 10
2431 {BGF(sic) number} 11
2433 {Dewey classification} 13
2434 {UDC classification} 14
2435 {Bliss classification} 15
2437 {NLM call number} 17
2438 {NAL call number} 18
2439 {MOS call number} 19
2440 {Local classification} 20
2441 {Subject heading} 21
2443 {BDI-index-subject} 23
2447 {LC-subject-heading} 27
2448 {RVM-subject-heading} 28
2449 {Local subject index} 29
2451 {Date of publication} 31
2452 {Date of acquisition} 32
2454 {Title-collective} 34
2457 {Title-added-title-page} 37
2461 {Title-other-variant} 41
2463 {Title-abbreviated} 43
2467 {Subject-subdivision} 47
2468 {Number-natl-bibliography} 48
2469 {Number-legal-deposit} 49
2470 {Number-govt-publication} 50
2471 {Number-publisher-for-music} 51
2473 {Number-local-call} 53
2475 {Code-geographic-area} 55
2476 {Code-institution} 56
2478 {Name-geographic} 58
2479 {Place-publication} 59
2481 {Microform-generation} 61
2488 {Author-name-personal} 1004
2489 {Author-name-corporate} 1005
2490 {Author-name-conference} 1006
2491 {Identifier-standard} 1007
2492 {Subject-LC-children's} 1008
2493 {Subject-name-personal} 1009
2495 {Date/time added to database} 1011
2496 {Date/time last modified} 1012
2497 {Authority/format identifier} 1013
2499 {Concept-reference} 1015
2501 {Server choice} 1017
2503 {Record source} 1019
2506 {Geographic class} 1022
2510 {Related periodical} 1026
2511 {Report number} 1027
2513 {Thematic number} 1030
2514 {Material type} 1031
2522 set l [llength $attr]
2527 for {set i 0} {$i < $l} {incr i} {
2528 $w.top.use.list insert end [lindex $attr $i]
2530 if {$useTmpValue == [lindex $attr $i]} {
2536 $w.top.use.list selection clear 0 end
2537 $w.top.use.list selection set $s $s
2539 $w.top.use.list select from $s
2540 $w.top.use.list select to $s
2546 $w.top.use.list yview $s
2548 set lno [lindex [$w.top.use.list curselection] 0]
2549 set i [expr $lno+$lno+1]
2550 set useTmpValue [lindex $attr $i]
2551 dputs "useTmpValue=$useTmpValue"
2555 proc index-setup-action {oldAttr queryNo indexNo} {
2556 set attr [lindex $oldAttr 0]
2559 global relationTmpValue
2560 global structureTmpValue
2561 global truncationTmpValue
2562 global completenessTmpValue
2563 global positionTmpValue
2568 dputs "index-setup-action"
2569 dputs "queryNo $queryNo"
2570 dputs "indexNo $indexNo"
2571 if {$useTmpValue > 0} {
2572 lappend attr "1=$useTmpValue"
2574 if {$relationTmpValue > 0} {
2575 lappend attr "2=$relationTmpValue"
2577 if {$positionTmpValue > 0} {
2578 lappend attr "3=$positionTmpValue"
2580 if {$structureTmpValue > 0} {
2581 lappend attr "4=$structureTmpValue"
2583 if {$truncationTmpValue > 0} {
2584 lappend attr "5=$truncationTmpValue"
2586 if {$completenessTmpValue > 0} {
2587 lappend attr "6=$completenessTmpValue"
2589 dputs "new attr $attr"
2590 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2591 destroy .index-setup
2594 proc index-setup {attr queryNo indexNo} {
2597 global relationTmpValue
2598 global structureTmpValue
2599 global truncationTmpValue
2600 global completenessTmpValue
2601 global positionTmpValue
2603 set relationTmpValue 0
2604 set truncationTmpValue 0
2605 set structureTmpValue 0
2606 set positionTmpValue 0
2607 set completenessTmpValue 0
2613 set n [lindex $attr 0]
2614 wm title $w "Index setup $n"
2618 set len [llength $attr]
2619 for {set i 1} {$i < $len} {incr i} {
2620 set q [lindex $attr $i]
2621 set l [string first = $q]
2623 set t [string range $q 0 [expr $l - 1]]
2624 set v [string range $q [expr $l + 1] end]
2627 { set useTmpValue $v }
2629 { set relationTmpValue $v }
2631 { set positionTmpValue $v }
2633 { set structureTmpValue $v }
2635 { set truncationTmpValue $v }
2637 { set completenessTmpValue $v }
2642 frame $w.top.use -relief ridge -border 2
2643 frame $w.top.relation -relief ridge -border 2
2644 frame $w.top.position -relief ridge -border 2
2645 frame $w.top.structure -relief ridge -border 2
2646 frame $w.top.truncation -relief ridge -border 2
2647 frame $w.top.completeness -relief ridge -border 2
2653 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2655 label $w.top.use.label -text "Use"
2657 listbox $w.top.use.list -width 26 \
2658 -yscrollcommand "$w.top.use.scroll set"
2660 listbox $w.top.use.list -geometry 26x10 \
2661 -yscrollcommand "$w.top.use.scroll set"
2663 scrollbar $w.top.use.scroll -orient vertical -border 1
2664 pack $w.top.use.label -side top -fill x \
2666 pack $w.top.use.list -side left -fill both -expand yes \
2668 pack $w.top.use.scroll -side right -fill y \
2670 $w.top.use.scroll config -command "$w.top.use.list yview"
2674 # Relation Attributes
2676 pack $w.top.relation -pady 6 -padx 6 -side top
2677 label $w.top.relation.label -text "Relation" -width 18
2679 pack $w.top.relation.label $w.top.relation.b -fill x
2681 # Position Attributes
2683 pack $w.top.position -pady 6 -padx 6 -side top
2684 label $w.top.position.label -text "Position" -width 18
2686 pack $w.top.position.label $w.top.position.b -fill x
2688 # Structure Attributes
2690 pack $w.top.structure -pady 6 -padx 6 -side top
2691 label $w.top.structure.label -text "Structure" -width 18
2693 pack $w.top.structure.label $w.top.structure.b -fill x
2695 # Truncation Attributes
2697 pack $w.top.truncation -pady 6 -padx 6 -side top
2698 label $w.top.truncation.label -text "Truncation" -width 18
2700 pack $w.top.truncation.label $w.top.truncation.b -fill x
2702 # Completeness Attributes
2704 pack $w.top.completeness -pady 6 -padx 6 -side top
2705 label $w.top.completeness.label -text "Completeness" -width 18
2707 pack $w.top.completeness.label $w.top.completeness.b -fill x
2710 bottom-buttons $w [list \
2711 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2712 {Cancel} [list destroy $w]] 0
2716 proc query-edit-index {queryNo} {
2720 set i [lindex [$w.top.index.list curselection] 0]
2724 set attr [lindex $queryInfoTmp $i]
2725 dputs "Editing no $i $attr"
2726 index-setup $attr $queryNo $i
2729 proc query-delete-index {queryNo} {
2731 global queryButtonsTmp
2734 set i [lindex [$w.top.index.list curselection] 0]
2738 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2739 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2740 $w.top.index.list delete $i
2743 proc query-setup {queryNo} {
2749 global queryButtonsTmp
2751 global queryIndexTmp
2754 set queryName [lindex $queryTypes $queryNo]
2755 set queryInfoTmp [lindex $queryInfo $queryNo]
2756 set queryButtonsTmp [lindex $queryButtons $queryNo]
2761 wm title $w "Query setup $queryName"
2765 frame $w.top.lines -relief ridge -border 2
2767 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2771 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2773 button $w.top.lines.add -text "Add" \
2774 -command [list query-add-line $queryNo]
2775 button $w.top.lines.del -text "Remove" \
2776 -command [list query-del-line $queryNo]
2778 pack $w.top.lines.del -fill x -side bottom
2779 pack $w.top.lines.add -fill x -pady 10 -side bottom
2783 frame $w.top.index -relief ridge -border 2
2784 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2786 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2787 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2788 -command [list $w.top.index.list yview]
2789 bind $w.top.index.list <Double-1> [list query-edit-index $queryNo]
2791 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2792 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2795 $w.top.index.list selection clear 0 end
2796 $w.top.index.list selection set 0 0
2798 $w.top.index.list select from 0
2799 $w.top.index.list select to 0
2802 foreach x $queryInfoTmp {
2803 $w.top.index.list insert end [lindex $x 0]
2807 bottom-buttons $w [list \
2808 Ok [list query-setup-action $queryNo] \
2809 Add [list query-add-index $queryNo] \
2810 Edit [list query-edit-index $queryNo] \
2811 Delete [list query-delete-index $queryNo] \
2812 Cancel [list destroy $w]] 0
2815 proc index-clear {} {
2816 global queryButtonsFind
2819 foreach b $queryButtonsFind {
2820 .lines.$i.e delete 0 end
2825 proc index-query {} {
2826 global queryButtonsFind
2827 global queryInfoFind
2832 foreach b $queryButtonsFind {
2833 set term [string trim [.lines.$i.e get]]
2835 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
2838 set len [string length $term]
2842 if {[string index $term 0] == ">"} {
2843 if {[string index $term 1] == "=" } {
2844 set term [string trim [string range $term 2 $len]]
2847 set term [string trim [string range $term 1 $len]]
2850 } elseif {[string index $term 0] == "<"} {
2851 if {[string index $term 1] == "=" } {
2852 set term [string trim [string range $term 2 $len]]
2854 } elseif {[string index $term 1] == ">"} {
2855 set term [string trim [string range $term 2 $len]]
2858 set term [string trim [string range $term 1 $len]]
2863 set len [string length $term]
2867 if {[string index $term $len] == "?"} {
2869 set term [string range $term 0 [expr $len - 1]]
2871 if {[string index $term 0] == "?"} {
2873 set term [string range $term 1 end]
2875 set term "\{${term}\}"
2876 if {$right && $left} {
2877 set term "@attr 5=3 ${term}"
2879 set term "@attr 5=1 ${term}"
2881 set term "@attr 5=2 ${term}"
2883 if {$relation != ""} {
2884 set term "@attr 2=${relation} ${term}"
2887 set term "@attr $a ${term}"
2890 set qs "@and ${qs} ${term}"
2901 proc index-focus-in {w i} {
2902 global curIndexEntry
2905 $w.$i configure -background red
2907 set curIndexEntry $i
2910 proc index-lines {w realOp buttonInfo queryInfo handle} {
2912 foreach b $buttonInfo {
2913 if {! [winfo exists $w.$i]} {
2915 frame $w.$i -border 0
2917 frame $w.$i -background white -border 1
2920 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
2923 if {! [winfo exists $w.$i.e]} {
2924 entry $w.$i.e -width 32 -relief sunken -border 1
2925 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
2926 bind $w.$i.e <FocusOut> [list $w.$i configure \
2928 pack $w.$i.l -side left
2929 pack $w.$i.e -side left -fill x -expand yes
2930 pack $w.$i -side top -fill x -padx 2 -pady 2
2932 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2933 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2935 bind $w.$i.e <Return> {search-request 0}
2938 pack $w.$i.l -side left
2939 pack $w.$i -side top -fill x -padx 2 -pady 2
2944 while {[winfo exists $w.$j]} {
2956 bind $w.$j.e <Tab> "focus $w.$k.e"
2962 bind $w.$i.e <Tab> "focus $w.0.e"
2968 proc search-fields {w buttondefs} {
2970 foreach buttondef $buttondefs {
2971 frame $w.$i -background white
2973 listbutton $w.$i.l 0 $buttondef
2974 entry $w.$i.e -width 32 -relief sunken
2976 pack $w.$i.l -side left
2977 pack $w.$i.e -side left -fill x -expand yes
2979 pack $w.$i -side top -fill x -padx 2 -pady 2
2981 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2982 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2990 bind $w.$j.e <Tab> "focus $w.$k.e \n
2991 $w.$k configure -background red \n
2992 $w.$j configure -background white"
2995 bind $w.$i.e <Tab> "focus $w.0.e \n
2996 $w.0 configure -background red \n
2997 $w.$i configure -background white"
2999 $w.0 configure -background red
3002 if {[info exists windowGeometry(.)]} {
3003 set g $windowGeometry(.)
3011 frame .top -border 1 -relief raised
3012 frame .lines -border 1 -relief raised
3013 frame .mid -border 1 -relief raised
3014 frame .data -border 1 -relief raised
3015 frame .bot -border 1 -relief raised
3016 pack .top .lines .mid -side top -fill x
3017 pack .data -side top -fill both -expand yes
3020 menubutton .top.file -text "File" -menu .top.file.m
3022 .top.file.m add command -label "Save settings" -command {save-settings}
3023 .top.file.m add separator
3024 .top.file.m add command -label "Exit" -command {exit-action}
3026 menubutton .top.target -text "Target" -menu .top.target.m
3028 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
3029 .top.target.m add command -label "Disconnect" -command {close-target}
3030 .top.target.m add command -label "About" -command {about-target}
3031 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
3032 .top.target.m add command -label "Setup new" -command {define-target-dialog}
3033 .top.target.m add separator
3034 set-target-hotlist 0
3036 configure-disable-e .top.target.m 1
3037 configure-disable-e .top.target.m 2
3039 menu .top.target.m.clist
3040 menu .top.target.m.slist
3043 menubutton .top.service -text "Service" -menu .top.service.m
3045 .top.service.m add command -label "Database" -command {database-select}
3046 .top.service.m add cascade -label "Present" -menu .top.service.m.present
3047 menu .top.service.m.present
3048 .top.service.m.present add command -label "10 More" \
3049 -command [list present-more 10]
3050 .top.service.m.present add command -label "All" \
3051 -command [list present-more {}]
3052 .top.service.m add command -label "Search" -command {search-request 0}
3053 .top.service.m add command -label "Scan" -command {scan-request}
3055 .top.service configure -state disabled
3057 menubutton .top.rset -text "Set" -menu .top.rset.m
3059 .top.rset.m add command -label "Load" -command {load-set}
3060 .top.rset.m add separator
3062 menubutton .top.options -text "Options" -menu .top.options.m
3064 .top.options.m add cascade -label "Query" -menu .top.options.m.query
3065 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
3066 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
3067 .top.options.m add cascade -label "Syntax" -menu .top.options.m.syntax
3068 .top.options.m add cascade -label "Elements" -menu .top.options.m.elements
3070 menu .top.options.m.query
3071 .top.options.m.query add cascade -label "Select" \
3072 -menu .top.options.m.query.clist
3073 .top.options.m.query add cascade -label "Edit" \
3074 -menu .top.options.m.query.slist
3075 .top.options.m.query add command -label "New" \
3076 -command {query-new}
3077 .top.options.m.query add cascade -label "Delete" \
3078 -menu .top.options.m.query.dlist
3080 menu .top.options.m.query.slist
3081 menu .top.options.m.query.clist
3082 menu .top.options.m.query.dlist
3085 menu .top.options.m.formats
3087 foreach f $displayFormats {
3088 .top.options.m.formats add radiobutton -label $f -value $i \
3089 -command [list set-display-format $i] -variable displayFormat
3093 menu .top.options.m.wrap
3094 .top.options.m.wrap add radiobutton -label "Character" \
3095 -value char -variable textWrap -command {set-wrap char}
3096 .top.options.m.wrap add radiobutton -label "Word" \
3097 -value word -variable textWrap -command {set-wrap word}
3098 .top.options.m.wrap add radiobutton -label "None" \
3099 -value none -variable textWrap -command {set-wrap none}
3101 menu .top.options.m.syntax
3102 .top.options.m.syntax add radiobutton -label "None" \
3103 -value None -variable recordSyntax
3104 .top.options.m.syntax add separator
3105 .top.options.m.syntax add radiobutton -label "USMARC" \
3106 -value USMARC -variable recordSyntax
3107 .top.options.m.syntax add radiobutton -label "UNIMARC" \
3108 -value UNIMARC -variable recordSyntax
3109 .top.options.m.syntax add radiobutton -label "UKMARC" \
3110 -value UKMARC -variable recordSyntax
3111 .top.options.m.syntax add radiobutton -label "DANMARC" \
3112 -value DANMARC -variable recordSyntax
3113 .top.options.m.syntax add radiobutton -label "FINMARC" \
3114 -value FINMARC -variable recordSyntax
3115 .top.options.m.syntax add radiobutton -label "NORMARC" \
3116 -value NORMARC -variable recordSyntax
3117 .top.options.m.syntax add radiobutton -label "PICAMARC" \
3118 -value PICAMARC -variable recordSyntax
3119 .top.options.m.syntax add separator
3120 .top.options.m.syntax add radiobutton -label "SUTRS" \
3121 -value SUTRS -variable recordSyntax
3122 .top.options.m.syntax add separator
3123 .top.options.m.syntax add radiobutton -label "GRS1" \
3124 -value GRS1 -variable recordSyntax
3126 menu .top.options.m.elements
3127 .top.options.m.elements add radiobutton -label "Unspecified" \
3128 -value None -variable elementSetNames
3129 .top.options.m.elements add radiobutton -label "Full" \
3130 -value F -variable elementSetNames
3131 .top.options.m.elements add radiobutton -label "Brief" \
3132 -value B -variable elementSetNames
3134 menubutton .top.help -text "Help" -menu .top.help.m
3137 .top.help.m add command -label "Help on help" \
3138 -command {tkerror "Help on help not available. Sorry"}
3139 .top.help.m add command -label "About" -command {about-origin}
3141 pack .top.file .top.target .top.service .top.rset .top.options -side left
3142 pack .top.help -side right
3144 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
3146 button .mid.search -text Search -command {search-request 0} \
3148 button .mid.scan -text Scan \
3149 -command scan-request -state disabled
3150 button .mid.present -text {Present} -command [list present-more 10] \
3153 button .mid.clear -text Clear -command index-clear
3154 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
3157 text .data.record -height 2 -width 20 -wrap none \
3158 -yscrollcommand [list .data.scroll set] -wrap $textWrap
3159 scrollbar .data.scroll -command [list .data.record yview]
3161 .data.record configure -takefocus 0
3162 .data.scroll configure -takefocus 0
3164 pack .data.scroll -side right -fill y
3165 pack .data.record -expand yes -fill both
3169 .data.record tag configure marc-tag -foreground blue
3170 .data.record tag configure marc-id -foreground red
3172 .data.record tag configure marc-tag -foreground black
3173 .data.record tag configure marc-id -foreground black
3175 .data.record tag configure marc-data -foreground black
3176 .data.record tag configure marc-head \
3177 -font -Adobe-Times-Bold-R-Normal-*-140-* \
3178 -foreground brown -relief raised -borderwidth 1
3179 .data.record tag configure marc-small-head -foreground brown
3180 .data.record tag configure marc-pref \
3181 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3183 .data.record tag configure marc-text \
3184 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3186 .data.record tag configure marc-it \
3187 -font -Adobe-Times-Medium-I-Normal-*-140-* \
3190 button .bot.logo -bitmap @${libdir}/bitmaps/book1 -command cancel-operation
3192 .bot.logo configure -takefocus 0
3195 pack .bot.a -side left -fill x
3196 pack .bot.logo -side right -padx 2 -pady 2 -ipadx 1
3198 message .bot.a.target -text "" -aspect 1000 -border 1
3200 label .bot.a.status -text "Not connected" -width 15 -relief \
3201 sunken -anchor w -border 1
3202 label .bot.a.set -text "" -width 5 -relief \
3203 sunken -anchor w -border 1
3204 label .bot.a.message -text "" -width 15 -relief \
3205 sunken -anchor w -border 1
3207 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
3208 pack .bot.a.status .bot.a.set .bot.a.message \
3209 -side left -padx 2 -pady 2 -ipadx 1 -ipady 1
3211 if {[catch {ir z39}]} {
3212 set e [info sharedlibextension]
3213 puts -nonewline "Loading irtcl$e ..."