1 # IR toolkit for tcl/tk
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
7 # Revision 1.77 1995-10-18 15:37:46 adam
10 # Revision 1.76 1995/10/18 15:15:20 adam
13 # Revision 1.75 1995/10/17 14:18:05 adam
14 # Minor changes in presentation formats.
16 # Revision 1.74 1995/10/17 12:18:57 adam
17 # Bug fix: when target connection closed, the connection was not
18 # properly reestablished.
20 # Revision 1.73 1995/10/17 10:58:06 adam
21 # More work on presentation formats.
23 # Revision 1.72 1995/10/16 17:00:52 adam
24 # New setting: elementSetNames.
25 # Various client improvements. Medium presentation format looks better.
27 # Revision 1.71 1995/10/13 15:35:27 adam
28 # Relational operators may be used in search entries - changes
29 # in proc index-query.
31 # Revision 1.70 1995/10/12 14:46:52 adam
32 # Better record popup windows. Next/prev buttons in popup record windows.
33 # The record position in the raw format is much more visible.
35 # Revision 1.69 1995/09/21 13:42:54 adam
38 # Revision 1.68 1995/09/21 13:11:49 adam
39 # Support of dynamic loading.
40 # Test script uses load command if necessary.
42 # Revision 1.67 1995/09/20 14:35:19 adam
45 # Revision 1.66 1995/08/29 15:30:13 adam
46 # Work on GRS records.
48 # Revision 1.65 1995/08/24 15:39:09 adam
51 # Revision 1.64 1995/08/24 15:33:02 adam
54 # Revision 1.63 1995/08/04 13:20:48 adam
55 # Buttons at the bottom are slightly smaller.
57 # Revision 1.62 1995/08/04 11:32:37 adam
58 # More work on output queue. Memory related routines moved
61 # Revision 1.61 1995/07/20 08:09:39 adam
62 # client.tcl: Targets removed from hotTargets list when targets
63 # are removed/modified.
64 # ir-tcl.c: More work on triggerResourceControl.
66 # Revision 1.60 1995/06/30 16:30:19 adam
69 # Revision 1.59 1995/06/29 14:06:25 adam
70 # Another bug in install fixed. Configure searches for more versions of yaz.
72 # Revision 1.58 1995/06/29 12:34:06 adam
73 # IrTcl now works with both tk4.0b4/tcl7.4b4 and tk3.6/tcl7.3
75 # Revision 1.57 1995/06/29 09:20:30 adam
76 # Target entries in cascade menus are sorted.
78 # Revision 1.56 1995/06/27 19:03:48 adam
79 # Bug fix in do_present in ir-tcl.c: p->set_child member weren't set.
80 # nextResultSetPosition used instead of setOffset.
82 # Revision 1.55 1995/06/27 17:10:37 adam
83 # Bug fix: install procedure didn't work on some systems.
84 # Error turned up when clientrc.tcl was't present.
86 # Revision 1.54 1995/06/27 14:41:03 adam
87 # Bug fix in search-response. Didn't always observe non-surrogate diagnostics.
89 # Revision 1.53 1995/06/26 12:40:09 adam
90 # Client defines its own tkerror.
91 # User may specify 'no preferredRecordSyntax'.
93 # Revision 1.52 1995/06/22 13:14:59 adam
94 # Feature: SUTRS. Setting getSutrs implemented.
95 # Work on display formats.
96 # Preferred record syntax can be set by the user.
98 # Revision 1.51 1995/06/21 11:11:00 adam
99 # Bug fix: libdir undefined in about-origin.
101 # Revision 1.50 1995/06/21 11:04:48 adam
102 # Uses GNU autoconf 2.3.
103 # Install procedure implemented.
104 # boook bitmaps moved to sub directory bitmaps.
106 # Revision 1.49 1995/06/20 14:16:42 adam
107 # More work on cancel mechanism.
109 # Revision 1.48 1995/06/20 08:07:23 adam
110 # New setting: failInfo.
111 # Working on better cancel mechanism.
113 # Revision 1.47 1995/06/19 14:05:29 adam
114 # Bug fix: asked for SUTRS.
116 # Revision 1.46 1995/06/19 13:06:06 adam
117 # New define: IR_TCL_VERSION.
119 # Revision 1.45 1995/06/19 08:08:44 adam
120 # client.tcl: hotTargets now contain both database and target name.
121 # ir-tcl.c: setting protocol edited. Errors in callbacks are logged
122 # by logf(LOG_WARN, ...) calls.
124 # Revision 1.44 1995/06/16 14:55:18 adam
125 # Book logo mirrored.
127 # Revision 1.43 1995/06/16 14:41:05 adam
128 # Scan line entries can be copied to a search entry.
130 # Revision 1.42 1995/06/16 12:28:13 adam
131 # Implemented preferredRecordSyntax.
132 # Minor changes in diagnostic handling.
133 # Record list deleted when connection closes.
135 # Revision 1.41 1995/06/14 15:07:59 adam
136 # Bug fix in cascade-target-list. Uses yaz-version.h.
138 # Revision 1.40 1995/06/14 13:37:17 adam
139 # Setting recordType implemented.
140 # Setting implementationVersion implemented.
141 # Settings implementationId / implementationName edited.
143 # Revision 1.39 1995/06/14 12:16:22 adam
144 # hotTargets, textWrap and displayFormat saved in clientg.tcl.
146 # Revision 1.38 1995/06/14 07:22:45 adam
147 # Target definitions can be deleted.
148 # Listbox used in the query definition dialog.
150 # Revision 1.37 1995/06/13 14:37:59 adam
151 # Work on query setup.
152 # Better about origin/target.
153 # Better presentation formats.
155 # Revision 1.36 1995/06/13 07:42:14 adam
156 # Bindings removed from text widgets.
158 # Revision 1.35 1995/06/12 15:17:31 adam
159 # Text widget used in main window (instead of listbox) to support
160 # better presentation formats.
162 # Revision 1.34 1995/06/12 07:59:07 adam
163 # More work on geometry handling.
165 # Revision 1.33 1995/06/09 11:17:35 adam
166 # Start work on geometry management.
168 # Revision 1.32 1995/06/07 09:16:37 adam
169 # New presentation format.
171 # Revision 1.31 1995/06/06 16:31:09 adam
172 # Bug fix: target names couldn't contain blanks.
175 # Revision 1.30 1995/06/06 11:35:41 adam
176 # Work on scan. Display of old sets.
178 # Revision 1.29 1995/06/05 14:11:18 adam
179 # Bug fix in present-more.
181 # Revision 1.28 1995/06/02 14:52:13 adam
182 # Minor changes really.
184 # Revision 1.27 1995/06/02 14:29:42 adam
185 # Work on scan interface - up/down buttons.
187 # Revision 1.26 1995/06/01 16:36:46 adam
188 # About buttons. Minor bug fixes.
190 # Revision 1.25 1995/05/31 13:09:57 adam
191 # Client searches/presents may be interrupted.
192 # New moving book-logo.
194 # Revision 1.24 1995/05/31 08:36:24 adam
195 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
196 # New method: referenceId. More work on scan.
198 # Revision 1.23 1995/05/29 10:33:41 adam
199 # README and rename of startup script.
201 # Revision 1.22 1995/05/26 11:44:09 adam
202 # Bugs fixed. More work on MARC utilities and queries. Test
203 # client is up-to-date again.
205 # Revision 1.21 1995/05/11 15:34:46 adam
206 # Scan request changed a bit. This version works with RLG.
208 # Revision 1.20 1995/04/21 16:31:57 adam
209 # New radiobutton: protocol (z39v2/SR).
211 # Revision 1.19 1995/04/18 16:11:50 adam
212 # First version of graphical Scan. Some work on query-by-form.
214 # Revision 1.18 1995/04/10 10:50:22 adam
215 # Result-set name defaults to suffix of ir-set name.
216 # Started working on scan. Not finished at this point.
218 # Revision 1.17 1995/03/31 09:34:57 adam
219 # Search-button disabled when there is no connection.
221 # Revision 1.16 1995/03/31 08:56:36 adam
222 # New button "Search".
224 # Revision 1.15 1995/03/28 12:45:22 adam
225 # New ir method failback: called on disconnect/protocol error.
226 # New ir set/get method: protocol: SR / Z3950.
227 # Simple popup and disconnect when failback is invoked.
229 # Revision 1.14 1995/03/22 16:07:55 adam
232 # Revision 1.13 1995/03/21 17:27:26 adam
233 # Short-hand keys in setup.
235 # Revision 1.12 1995/03/21 13:41:03 adam
236 # Comstack cs_create not used too often. Non-blocking connect.
238 # Revision 1.11 1995/03/21 10:39:06 adam
239 # Diagnostic error message displayed with tkerror.
241 # Revision 1.10 1995/03/20 15:24:06 adam
242 # Diagnostic records saved on searchResponse.
244 # Revision 1.9 1995/03/17 18:26:16 adam
245 # Non-blocking i/o used now. Database names popup as cascade items.
247 # Revision 1.8 1995/03/17 15:45:00 adam
248 # Improved target/database setup.
250 # Revision 1.7 1995/03/16 17:54:03 adam
251 # Minor changes really.
253 # Revision 1.6 1995/03/15 19:10:20 adam
254 # Database setup in protocol-setup (rather target setup).
256 # Revision 1.5 1995/03/15 13:59:23 adam
259 # Revision 1.4 1995/03/14 17:32:29 adam
260 # Presentation of full Marc record in popup window.
262 # Revision 1.3 1995/03/12 19:31:52 adam
263 # Pattern matching implemented when retrieving MARC records. More
264 # diagnostic functions.
266 # Revision 1.2 1995/03/10 18:00:15 adam
267 # Actual presentation in line-by-line format. RPN query support.
269 # Revision 1.1 1995/03/09 16:15:07 adam
270 # First presentRequest attempts. Hot-target list.
274 if {$tk_version == "3.6"} {
285 proc configure-enable-e {w n} {
287 $w entryconfigure $n -state normal
289 proc configure-disable-e {w n} {
291 $w entryconfigure $n -state disabled
293 set noFocus [list -takefocus 0]
295 proc configure-enable-e {w n} {
298 proc configure-disable-e {w n} {
305 if {[tk colormodel .] == "color"} {
315 if {[file readable bitmaps/book2]} {
318 if {! [file readable ${libdir}/bitmaps/book2]} {
319 puts "Cannot locate system files in ${libdir}. You must either run this"
320 puts "program from the source directory root of ir-tcl or you must assure"
321 puts "that it is installed - normally in /usr/local/lib/irtcl"
329 set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} Z39 1}
331 set settingsChanged 0
339 set recordSyntax None
340 set elementSetNames None
343 set queryTypes {Simple}
344 set queryButtons { { {I 0} {I 1} {I 2} } }
345 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
346 {Subject {1=21}} {Any {1=1016}} } }
355 if {[winfo exists $w]} {
364 label $w.top.b -bitmap error
365 message $w.top.t -aspect 300 -text "Error: $err" \
366 -font -Adobe-Helvetica-Bold-R-Normal-*-180-*
367 pack $w.top.b $w.top.t -side left -padx 10 -pady 10
369 bottom-buttons $w [list {Close} [list destroy $w]] 1
372 proc read-formats {} {
373 global displayFormats
375 if {[catch {set formats [glob -nocomplain ${libdir}/formats/*.tcl]}]} {
376 set formats ./formats/raw.tcl
379 if {[file readable $f]} {
381 set l [string length $f]
382 set f [string range $f [string length "${libdir}/formats/"] \
384 lappend displayFormats $f
393 .data.record configure -wrap $m
400 proc set-display-format {f} {
410 .bot.a.status configure -text "Reformatting"
413 add-title-lines -1 10000 1
416 proc initBindings {} {
419 bind $w <Double-1> {}
420 bind $w <Triple-1> {}
421 bind $w <B1-Motion> {}
423 bind $w <Shift-B1-Motion> {}
425 bind $w <B2-Motion> {}
426 bind $w <Any-KeyPress> {}
428 bind $w <BackSpace> {}
430 bind $w <Control-h> {}
431 bind $w <Control-d> {}
432 bind $w <Control-v> {}
435 bind $w <B1-Motion> {}
436 bind $w <Shift-B1-Motion> {}
441 proc post-menu {wbutton wmenu} {
444 $wmenu post [winfo rootx $wbutton] \
445 [expr [winfo rooty $wbutton]+[winfo height $wbutton]]
450 global windowGeometry
451 set windowGeometry($w) [wm geometry $w]
454 global windowGeometry
457 if {[info exists windowGeometry($w)]} {
458 set g $windowGeometry($w)
463 bind $w <Destroy> [list destroyGW $w]
466 if {[file readable "clientrc.tcl"]} {
467 source "clientrc.tcl"
469 if {[file readable "${libdir}/clientrc.tcl"]} {
470 source "${libdir}/clientrc.tcl"
474 if {[file readable "~/.clientrc.tcl"]} {
475 source "~/.clientrc.tcl"
478 set queryButtonsFind [lindex $queryButtons 0]
479 set queryInfoFind [lindex $queryInfo 0]
481 proc top-down-window {w} {
482 frame $w.top -relief raised -border 1
483 frame $w.bot -relief raised -border 1
485 pack $w.top -side top -fill both -expand yes
486 pack $w.bot -fill both
489 proc top-down-ok-cancel {w ok-action g} {
490 frame $w.bot.left -relief sunken -border 1
491 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 1 -pady 1
492 button $w.bot.left.ok -width 4 -text {Ok} \
493 -command ${ok-action}
494 pack $w.bot.left.ok -expand yes -ipadx 1 -ipady 1 -padx 2 -pady 2
495 button $w.bot.cancel -width 5 -text {Cancel} \
496 -command [list destroy $w]
497 pack $w.bot.cancel -side left -expand yes
505 proc bottom-buttons {w buttonList g} {
507 set l [llength $buttonList]
509 frame $w.bot.$i -relief sunken -border 1
510 pack $w.bot.$i -side left -expand yes -padx 2 -pady 2
511 button $w.bot.$i.ok -text [lindex $buttonList $i] \
512 -command [lindex $buttonList [expr $i+1]]
513 pack $w.bot.$i.ok -expand yes -padx 2 -pady 2 -side left
517 button $w.bot.$i -text [lindex $buttonList $i] \
518 -command [lindex $buttonList [expr $i+1]]
519 pack $w.bot.$i -expand yes -padx 2 -pady 2 -side left
529 proc cancel-operation {} {
537 show-status Cancel 0 1
541 proc show-target {target base} {
545 .bot.a.target configure -text ""
549 .bot.a.target configure -text "$target"
551 .bot.a.target configure -text "$target - $base"
555 proc show-logo {v1} {
564 .bot.logo configure -bitmap @${libdir}/bitmaps/book${v1}
565 after 140 [list show-logo $v1]
569 .bot.logo configure -bitmap @${libdir}/bitmaps/book1
578 proc show-status {status b sb} {
585 .bot.a.status configure -text "$status"
587 if {$busy == 0} {set busy 1}
595 .top.service configure -state normal
596 .mid.search configure -state normal
598 .mid.scan configure -state normal
601 configure-disable-e .top.service.m 1
602 } elseif {[z39.$setNo nextResultSetPosition] > 0 &&
603 [z39.$setNo nextResultSetPosition] <= [z39.$setNo resultCount]} {
604 configure-enable-e .top.service.m 1
605 .mid.present configure -state normal
607 configure-disable-e .top.service.m 1
608 .mid.present configure -state disabled
610 if {[winfo exists .scan-window]} {
611 .scan-window.bot.2 configure -state normal
612 .scan-window.bot.4 configure -state normal
615 .top.service configure -state disabled
616 .mid.search configure -state disabled
617 .mid.scan configure -state disabled
618 .mid.present configure -state disabled
620 if {[winfo exists .scan-window]} {
621 .scan-window.bot.2 configure -state disabled
622 .scan-window.bot.4 configure -state disabled
627 proc show-message {msg} {
628 .bot.a.message configure -text "$msg"
631 proc insertWithTags {w text args} {
632 set start [$w index insert]
633 $w insert insert $text
634 foreach tag [$w tag names $start] {
635 $w tag remove $tag $start insert
638 $w tag add $i $start insert
642 proc popup-license {} {
647 wm title $w "License"
653 text $w.top.t -width 80 -height 10 -wrap word \
654 -yscrollcommand [list $w.top.s set]
655 scrollbar $w.top.s -command [list $w.top.t yview]
657 pack $w.top.s -side right -fill y
658 pack $w.top.t -expand yes -fill both
660 if {[file readable "${libdir}/LICENSE"]} {
661 set f [open "${libdir}/LICENSE" r]
662 while {[gets $f buf] != -1} {
663 $w.top.t insert end $buf
664 $w.top.t insert end "\n"
668 bottom-buttons $w [list {Close} [list destroy $w]] 1
671 proc about-target {} {
672 set w .about-target-w
677 wm title $w "About target"
681 frame $w.top.a -relief ridge -border 2
682 frame $w.top.p -relief ridge -border 2
684 pack $w.top.a $w.top.p -side top -fill x
686 label $w.top.a.about -text "About"
687 label $w.top.a.irtcl -text $hostid \
688 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
689 pack $w.top.a.about $w.top.a.irtcl -side top
691 set i [z39 targetImplementationName]
692 label $w.top.p.in -text "Implementation name: $i"
693 set i [z39 targetImplementationId]
694 label $w.top.p.ii -text "Implementation id: $i"
695 set i [z39 targetImplementationVersion]
696 label $w.top.p.iv -text "Implementation version: $i"
698 label $w.top.p.op -text "Protocol options: $i"
700 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
702 bottom-buttons $w [list {Close} [list destroy $w]] 1
705 proc about-origin-logo {n} {
707 set w .about-origin-w
708 if {![winfo exists $w]} {
715 $w.top.a.logo configure -bitmap @${libdir}/bitmaps/book$n
716 after 140 [list about-origin-logo $n]
719 proc about-origin {} {
720 set w .about-origin-w
724 if {[winfo exists $w]} {
729 wm title $w "About IrTcl"
733 frame $w.top.a -relief ridge -border 2
734 frame $w.top.p -relief ridge -border 2
736 pack $w.top.a $w.top.p -side top -fill x
738 label $w.top.a.irtcl -text "IrTcl" \
739 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
740 label $w.top.a.logo -bitmap @${libdir}/bitmaps/book1
741 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
744 catch {set i [z39 implementationName]}
745 label $w.top.p.in -text "Implementation name: $i"
746 catch {set i [z39 implementationId]}
747 label $w.top.p.ii -text "Implementation id: $i"
748 catch {set i [z39 implementationVersion]}
749 label $w.top.p.iv -text "Implementation version: $i"
751 label $w.top.p.tk -text "Tk version: $i"
753 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.tk -side top -anchor nw
756 bottom-buttons $w [list {Close} [list destroy $w] \
757 {License} [list popup-license]] 0
760 proc popup-marc {sno no b df} {
761 global displayFormats
764 if {[z39.$sno type $no] != "DB"} {
769 while {[winfo exists .full-marc$b]} {
775 if {![winfo exists $w]} {
780 frame $w.top -relief raised -border 1
781 frame $w.bot -relief raised -border 1
783 pack $w.top -side top -fill both -expand yes
784 pack $w.bot -fill both
786 text $w.top.record -width 60 -height 5 -wrap word \
787 -yscrollcommand [list $w.top.s set]
788 scrollbar $w.top.s -command [list $w.top.record yview]
792 $w.top.record tag configure marc-tag -foreground blue
793 $w.top.record tag configure marc-id -foreground red
795 $w.top.record tag configure marc-tag -foreground black
796 $w.top.record tag configure marc-id -foreground black
798 $w.top.record tag configure marc-data -foreground black
799 $w.top.record tag configure marc-head \
800 -font -Adobe-Times-Medium-R-Normal-*-180-* \
801 -background black -foreground white
803 $w.top.record tag configure marc-pref \
804 -font -Adobe-Times-Medium-R-Normal-*-180-* \
806 $w.top.record tag configure marc-text \
807 -font -Adobe-Times-Medium-R-Normal-*-180-* \
809 $w.top.record tag configure marc-it \
810 -font -Adobe-Times-Medium-I-Normal-*-180-* \
813 pack $w.top.s -side right -fill y
814 pack $w.top.record -expand yes -fill both
816 bottom-buttons $w [list \
817 {Close} [list destroy $w] \
821 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m \
823 menu $w.bot.formats.m
824 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 \
825 -padx 3 -pady 3 -side left
827 $w.bot.formats.m delete 0 last
830 foreach f $displayFormats {
831 $w.bot.formats.m add radiobutton -label $f \
832 -variable popupMarcdf -value $i \
833 -command [list popup-marc $sno $no $b 0]
836 $w.top.record delete 0.0 end
837 set recordType [z39.$sno recordType $no]
838 wm title $w "$recordType record #$no"
840 $w.bot.2 configure -command \
841 [list popup-marc $sno [expr $no-1] $b $df]
842 $w.bot.4 configure -command \
843 [list popup-marc $sno [expr $no+1] $b $df]
845 $w.bot.2 configure -state disabled
847 $w.bot.2 configure -state normal
849 if {[z39.$sno type [expr $no+1]] != "DB"} {
850 $w.bot.4 configure -state disabled
852 $w.bot.4 configure -state normal
854 $w.bot.6 configure -command [list popup-marc $sno $no -1 0]
855 set ffunc [lindex $displayFormats $df]
856 set ffunc "display-$ffunc"
858 $ffunc $sno $no $w.top.record 0
861 proc update-target-hotlist {target base} {
864 set olen [llength $hotTargets]
866 foreach e $hotTargets {
867 if {$target == [lindex $e 0] && $base == [lindex $e 1]} {
868 set hotTargets [lreplace $hotTargets $i $i]
873 set hotTargets [linsert $hotTargets 0 [list $target $base]]
874 set-target-hotlist $olen
877 proc delete-target-hotlist {target} {
880 set olen [llength $hotTargets]
882 foreach e $hotTargets {
883 if {$target == [lindex $e 0]} {
884 set hotTargets [lreplace $hotTargets $i $i]
888 set-target-hotlist $olen
891 proc set-target-hotlist {olen} {
896 .top.target.m delete 7 [expr 7+$olen]
898 .top.target.m delete 6 [expr 6+$olen]
902 foreach e $hotTargets {
903 set target [lindex $e 0]
904 set base [lindex $e 1]
906 .top.target.m add command -label "$i $target" -command \
907 [list reopen-target $target {}]
909 .top.target.m add command -label "$i $target - $base" -command \
910 [list reopen-target $target $base]
919 proc reopen-target {target base} {
921 open-target $target $base
922 update-target-hotlist $target $base
925 proc define-target-action {} {
928 set target [.target-define.top.target.entry get]
932 foreach n [array names profile] {
938 set seq [lindex $profile(Default) 12]
940 set profile($target) $profile(Default)
941 set profile(Default) [lreplace $profile(Default) 12 12 [incr seq]]
943 protocol-setup $target
944 destroy .target-define
947 proc fail-response {target} {
948 set c [lindex [z39 failInfo] 0]
949 set m [lindex [z39 failInfo] 1]
954 proc connect-response {target base} {
955 dputs "connect-response"
956 show-target $target $base
960 proc open-target {target base} {
965 z39 comstack [lindex $profile($target) 6]
966 z39 protocol [lindex $profile($target) 11]
967 z39 idAuthentication [lindex $profile($target) 3]
968 z39 maximumRecordSize [lindex $profile($target) 4]
969 z39 preferredMessageSize [lindex $profile($target) 5]
970 dputs "maximumRecordSize="
971 dputs [z39 maximumRecordSize]
972 dputs "preferredMessageSize="
973 dputs [z39 preferredMessageSize]
974 show-status Connecting 1 0
976 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
978 z39 databaseNames $base
980 z39 failback [list fail-response $target]
981 z39 callback [list connect-response $target $base]
984 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
987 tkerror $errorMessage
988 show-status "Not connected" 0 {}
992 configure-disable-e .top.target.m 0
993 configure-enable-e .top.target.m 1
994 configure-enable-e .top.target.m 2
997 proc close-target {} {
1006 .bot.a.set configure -text ""
1010 show-status {Not connected} 0 0
1013 configure-disable-e .top.target.m 1
1014 configure-disable-e .top.target.m 2
1016 .top.rset.m delete 2 last
1018 .top.rset.m delete 1 last
1020 .top.rset.m add separator
1021 configure-enable-e .top.target.m 0
1024 proc load-set-action {} {
1028 ir-set z39.$setNoLast z39
1030 set fname [.load-set.top.filename.entry get]
1033 show-status Loading 1 {}
1035 z39.$setNoLast loadFile $fname
1037 set no [z39.$setNoLast numberOfRecordsReturned]
1038 add-title-lines $setNoLast $no 1
1040 set l [format "%-4d %7d" $setNoLast $no]
1041 .top.rset.m add command -label $l \
1042 -command [list add-title-lines $setNoLast 10000 1]
1043 show-status Ready 0 {}
1049 set oldFocus [focus]
1053 frame $w.top.filename
1054 pack $w.top.filename -side top -anchor e -pady 2
1056 entry-fields $w.top {filename} \
1058 {load-set-action} {destroy .load-set}
1060 top-down-ok-cancel $w {load-set-action} 1
1064 proc init-request {} {
1071 z39 callback {init-response}
1072 show-status Initializing 1 {}
1073 set err [catch {z39 init} errorMessage]
1075 tkerror $errorMessage
1076 show-status Ready 0 {}
1080 proc init-response {} {
1084 dputs {init-reponse}
1089 if {![z39 initResult]} {
1090 show-status Ready 0 1
1091 set u [z39 userInformationField]
1093 tkerror "Connection rejected by target: $u"
1095 if {[lsearch [z39 options] scan] >= 0} {
1100 show-status Ready 0 1
1104 proc search-request {bflag} {
1113 global elementSetNames
1117 if {[z39 connect] == ""} {
1120 dputs "search-request"
1122 if {!$bflag && $busy} {
1123 dputs "busy: search-request ignored"
1128 show-status Searching 1 0
1129 set delayRequest {search-request 1}
1134 set query [index-query]
1139 set setNo $setNoLast
1140 ir-set z39.$setNo z39
1142 if {[lindex $profile($target) 10] == 1} {
1143 z39.$setNo setName $setNo
1144 dputs "setName=${setNo}"
1146 z39.$setNo setName Default
1147 dputs "setName=Default"
1149 if {[lindex $profile($target) 8] == 1} {
1150 z39.$setNo queryType rpn
1152 if {[lindex $profile($target) 9] == 1} {
1153 z39.$setNo queryType ccl
1157 if {$recordSyntax == "None" } {
1158 z39.$setNo preferredRecordSyntax {}
1160 z39.$setNo preferredRecordSyntax $recordSyntax
1162 if {$elementSetNames == "None" } {
1163 z39.$setNo elementSetNames {}
1165 z39.$setNo elementSetNames $elementSetNames
1167 z39 callback {search-response}
1168 z39.$setNo search $query
1169 show-status Searching 1 0
1172 proc scan-copy {y entry} {
1174 set no [$w.top.list nearest $y]
1176 .lines.$entry.e delete 0 end
1177 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
1180 proc scan-request {} {
1187 global curIndexEntry
1188 global queryButtonsFind
1189 global queryInfoFind
1193 dputs "scan-request"
1196 show-status Scanning 1 0
1197 set delayRequest scan-request
1206 set b [lindex $queryButtonsFind $curIndexEntry]
1208 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
1209 set attr "@attr $a $attr"
1211 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
1212 ir-scan z39.scan z39
1214 if {![winfo exists $w]} {
1221 entry $w.top.entry -relief sunken
1222 pack $w.top.entry -fill x -padx 4 -pady 2
1223 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
1224 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
1226 scrollbar $w.top.scroll -orient vertical -border 1
1227 pack $w.top.list -side left -fill both -expand yes
1228 pack $w.top.scroll -side right -fill y
1229 $w.top.scroll config -command [list $w.top.list yview]
1231 bottom-buttons $w [list {Close} [list destroy $w] \
1232 {Up} [list scan-up $attr] \
1233 {Down} [list scan-down $attr]] 0
1234 bind $w.top.list <Up> [list scan-up $attr]
1235 bind $w.top.list <Down> [list scan-down $attr]
1238 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
1239 wm title $w "Scan $title"
1241 z39 callback [list scan-response $attr 0 35]
1242 z39.scan numberOfTermsRequested 5
1243 z39.scan preferredPositionInResponse 1
1244 z39.scan scan "${attr} 0"
1246 show-status Scanning 1 0
1249 proc scan-term-h {attr} {
1257 set nScanTerm [$w.top.entry get]
1258 if {$nScanTerm == $scanTerm} {
1261 set scanTerm $nScanTerm
1262 z39 callback [list scan-response $attr 0 35]
1263 z39.scan numberOfTermsRequested 5
1264 z39.scan preferredPositionInResponse 1
1265 dputs "${attr} \{${scanTerm}\}"
1266 if {$scanTerm == ""} {
1267 z39.scan scan "${attr} 0"
1269 z39.scan scan "${attr} \{${scanTerm}\}"
1271 show-status Scanning 1 0
1274 proc scan-response {attr start toget} {
1281 dputs "In scan-response"
1282 set m [z39.scan numberOfEntriesReturned]
1288 if {![winfo exists .scan-window]} {
1291 dputs "Handling cancel"
1292 if {$delayRequest != ""} {
1297 show-status Ready 0 1
1300 set nScanTerm [$w.top.entry get]
1301 if {$nScanTerm != $scanTerm} {
1302 z39 callback [list scan-response $attr 0 35]
1303 z39.scan numberOfTermsRequested 5
1304 z39.scan preferredPositionInResponse 1
1305 set scanTerm $nScanTerm
1306 dputs "${attr} \{${scanTerm}\}"
1307 if {$scanTerm == ""} {
1308 z39.scan scan "${attr} 0"
1310 z39.scan scan "${attr} \{${scanTerm}\}"
1312 show-status Scanning 1 0
1315 set status [z39.scan scanStatus]
1318 show-status Ready 0 1
1323 for {set i 0} {$i < $m} {incr i} {
1324 set term [lindex [z39.scan scanLine $i] 1]
1325 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1326 $w.top.list insert $i "$nostr $term"
1329 $w.top.list yview $scanView
1331 $w.top.list delete $start end
1332 for {set i 0} {$i < $m} {incr i} {
1333 set term [lindex [z39.scan scanLine $i] 1]
1334 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1335 $w.top.list insert end "$nostr $term"
1339 dputs "Handling cancel"
1341 if {$delayRequest != ""} {
1347 if {$toget > 0 && $m > 1 && $m < $toget} {
1348 set ntoget [expr $toget - $m + 1]
1349 dputs ntoget=$ntoget
1350 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1352 dputs "down continue: $q"
1354 z39.scan numberOfTermsRequested 10
1356 z39.scan numberOfTermsRequested $ntoget
1358 z39.scan preferredPositionInResponse 1
1359 dputs "${attr} \{$q\}"
1360 z39.scan scan "${attr} \{$q\}"
1363 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1364 set ntoget [expr - $toget - $m]
1365 dputs ntoget=$ntoget
1366 z39 callback [list scan-response $attr 0 -$ntoget]
1367 set q [string range [$w.top.list get 0] 8 end]
1368 dputs "up continue: $q"
1370 z39.scan numberOfTermsRequested 10
1371 z39.scan preferredPositionInResponse 11
1373 z39.scan numberOfTermsRequested $ntoget
1374 z39.scan preferredPositionInResponse [incr ntoget]
1376 dputs "${attr} \{$q\}"
1377 z39.scan scan "${attr} \{$q\}"
1380 show-status Ready 0 1
1383 proc scan-down {attr} {
1391 show-status {Scanning down} 1 0
1392 set delayRequest [list scan-down $attr]
1398 set scanView [expr $scanView + 5]
1399 set s [$w.top.list size]
1400 if {$scanView > $s} {
1401 z39 callback [list scan-response $attr [expr $s - 1] 25]
1402 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1404 z39.scan numberOfTermsRequested 10
1405 z39.scan preferredPositionInResponse 1
1406 show-status Scanning 1 0
1407 dputs "${attr} \{$q\}"
1408 z39.scan scan "${attr} \{$q\}"
1411 $w.top.list yview $scanView
1414 proc scan-up {attr} {
1422 show-status Scanning 1 0
1423 set delayRequest [list scan-up $attr]
1429 set scanView [expr $scanView - 5]
1430 if {$scanView < 0} {
1431 z39 callback [list scan-response $attr 0 -25]
1432 set q [string range [$w.top.list get 0] 8 end]
1434 z39.scan numberOfTermsRequested 10
1435 z39.scan preferredPositionInResponse 11
1436 show-status Scanning 1 0
1437 z39.scan scan "${attr} \{$q\}"
1440 $w.top.list yview $scanView
1443 proc search-response {} {
1451 dputs "In search-response"
1453 dputs "Handling cancel"
1455 if {$delayRequest != ""} {
1463 set setMax [z39.$setNo resultCount]
1464 show-status Ready 0 1
1465 set status [z39.$setNo responseStatus]
1466 if {[lindex $status 0] == "NSD"} {
1467 z39.$setNo nextResultSetPosition 0
1468 set code [lindex $status 1]
1469 set msg [lindex $status 2]
1470 set addinfo [lindex $status 3]
1471 tkerror "NSD$code: $msg: $addinfo"
1474 show-message "${setMax} hits"
1479 show-status Ready 0 1
1480 set l [format "%-4d %7d" $setNo $setMax]
1481 .top.rset.m add command -label $l \
1482 -command [list add-title-lines $setNo 10000 1]
1486 set no [z39.$setNo numberOfRecordsReturned]
1487 dputs "Returned $no records, setOffset $setOffset"
1488 add-title-lines $setNo $no $setOffset
1489 set setOffset [expr $setOffset + $no]
1490 z39 callback {present-response}
1491 z39.$setNo present $setOffset 1
1492 show-status Retrieving 1 0
1495 proc present-more {number} {
1503 dputs "present-more"
1505 show-status Retrieving 1 0
1506 set delayRequest "present-more $number"
1512 dputs "setNo=$setNo"
1515 set setOffset [z39.$setNo nextResultSetPosition]
1516 dputs "setOffest=${setOffset}"
1517 dputs "setNo=${setNo}"
1518 set max [z39.$setNo resultCount]
1519 if {$max < $setOffset} {
1521 dputs "setOffset=$setOffset"
1522 show-status Ready 0 1
1525 if {$number == ""} {
1529 if {$setMax > $max} {
1533 z39 callback {present-response}
1535 set toGet [expr $setMax - $setOffset + 1]
1542 z39.$setNo present $setOffset $toGet
1543 show-status Retrieving 1 0
1546 proc init-title-lines {} {
1547 .data.record delete 0.0 end
1550 proc add-title-lines {setno no offset} {
1551 global displayFormats
1552 global displayFormat
1562 .bot.a.set configure -text $setno
1563 .data.record delete 0.0 end
1565 set ffunc [lindex $displayFormats $displayFormat]
1566 dputs "ffunc=$ffunc"
1567 set ffunc "display-$ffunc"
1568 for {set i 0} {$i < $no} {incr i} {
1569 set o [expr $i + $offset]
1570 set type [z39.$setno type $o]
1574 .data.record tag bind r$o <Any-Enter> {}
1575 .data.record tag bind r$o <Any-Leave> {}
1576 set insert0 [.data.record index insert]
1577 $ffunc $setno $o .data.record 1
1578 .data.record tag add r$o $insert0 insert
1579 .data.record tag bind r$o <1> \
1580 [list popup-marc $setno $o 0 0]
1584 show-status Ready 0 1
1588 proc present-response {} {
1595 dputs "In present-response"
1596 set no [z39.$setNo numberOfRecordsReturned]
1597 dputs "Returned $no records, setOffset $setOffset"
1598 add-title-lines $setNo $no $setOffset
1599 set setOffset [expr $setOffset + $no]
1601 dputs "Handling cancel"
1603 if {$delayRequest != ""} {
1608 set status [z39.$setNo responseStatus]
1609 if {[lindex $status 0] == "NSD"} {
1610 show-status Ready 0 1
1611 set code [lindex $status 1]
1612 set msg [lindex $status 2]
1613 set addinfo [lindex $status 3]
1614 tkerror "NSD$code: $msg: $addinfo"
1617 if {$no > 0 && $setOffset <= $setMax} {
1618 dputs "present-request from ${setOffset}"
1619 set toGet [expr $setMax - $setOffset + 1]
1623 z39.$setNo present $setOffset $toGet
1625 show-status Ready 0 1
1629 proc left-cursor {w} {
1630 set i [$w index insert]
1638 proc right-cursor {w} {
1639 set i [$w index insert]
1645 proc bind-fields {list returnAction escapeAction} {
1646 set max [expr [llength $list]-1]
1647 for {set i 0} {$i < $max} {incr i} {
1648 bind [lindex $list $i] <Return> $returnAction
1649 bind [lindex $list $i] <Escape> $escapeAction
1651 bind [lindex $list $i] <Tab> \
1652 [list focus [lindex $list [expr $i+1]]]
1653 bind [lindex $list $i] <Left> \
1654 [list left-cursor [lindex $list $i]]
1655 bind [lindex $list $i] <Right> \
1656 [list right-cursor [lindex $list $i]]
1659 bind [lindex $list $i] <Return> $returnAction
1660 bind [lindex $list $i] <Escape> $escapeAction
1662 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1663 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1664 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1666 focus [lindex $list 0]
1669 proc entry-fields {parent list tlist returnAction escapeAction} {
1672 foreach field $list {
1673 set label ${parent}.${field}.label
1674 set entry ${parent}.${field}.entry
1675 label $label -text [lindex $tlist $i] -anchor e
1676 entry $entry -width 32 -relief sunken
1677 pack $label -side left
1678 pack $entry -side right
1679 lappend alist $entry
1682 bind-fields $alist $returnAction $escapeAction
1685 proc define-target-dialog {} {
1686 set w .target-define
1692 pack $w.top.target \
1693 -side top -anchor e -pady 2
1694 entry-fields $w.top {target} \
1696 {define-target-action} {destroy .target-define}
1697 top-down-ok-cancel $w {define-target-action} 1
1700 proc protocol-setup-delete {target w} {
1702 global settingsChanged
1704 set a [alert "Are you sure you want to delete the target \
1705 definition $target ?"]
1708 unset profile($target)
1709 set settingsChanged 1
1711 delete-target-hotlist $target
1715 proc protocol-setup-action {target w} {
1718 global protocolRadioType
1719 global settingsChanged
1722 global ResultSetCheck
1725 set settingsChanged 1
1726 set len [$w.top.databases.list size]
1727 for {set i 0} {$i < $len} {incr i} {
1728 lappend b [$w.top.databases.list get $i]
1730 set wno [lindex $profile($target) 12]
1732 set profile($target) [list [$w.top.description.entry get] \
1733 [$w.top.host.entry get] \
1734 [$w.top.port.entry get] \
1735 [$w.top.idAuthentication.entry get] \
1736 [$w.top.maximumRecordSize.entry get] \
1737 [$w.top.preferredMessageSize.entry get] \
1743 $protocolRadioType \
1747 delete-target-hotlist $target
1748 dputs $profile($target)
1752 proc place-force {window parent} {
1753 set g [wm geometry $parent]
1755 set p1 [string first + $g]
1756 set p2 [string last + $g]
1758 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1759 set y [expr 60+[string range $g [expr $p2 +1] end]]
1760 wm geometry $window +${x}+${y}
1763 proc add-database-action {target w} {
1766 $w.top.databases.list insert end \
1767 [.database-select.top.database.entry get]
1768 destroy .database-select
1771 proc add-database {target wp} {
1774 set w .database-select
1776 set oldFocus [focus]
1782 frame $w.top.database
1784 pack $w.top.database -side top -anchor e -pady 2
1786 entry-fields $w.top {database} \
1787 {{Database to add:}} \
1788 [list add-database-action $target $wp] {destroy .database-select}
1790 top-down-ok-cancel $w [list add-database-action $target $wp] 1
1794 proc delete-database {target w} {
1798 foreach i [$w.top.databases.list curselection] {
1799 set b [$w.top.databases.list get $i]
1802 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1804 foreach i [lsort -decreasing \
1805 [$w.top.databases.list curselection]] {
1806 $w.top.databases.list delete $i
1811 proc protocol-setup {target} {
1814 global protocolRadioType
1817 global ResultSetCheck
1820 while {[winfo exists .setup-$b]} {
1827 wm title $w "Setup $target"
1831 if {$target == ""} {
1835 dputs $profile($target)
1837 frame $w.top.description
1840 frame $w.top.idAuthentication
1841 frame $w.top.maximumRecordSize
1842 frame $w.top.preferredMessageSize
1843 frame $w.top.cs-type -relief ridge -border 2
1844 frame $w.top.protocol -relief ridge -border 2
1845 frame $w.top.query -relief ridge -border 2
1846 frame $w.top.databases -relief ridge -border 2
1848 # Maximum/preferred/idAuth ...
1849 pack $w.top.description $w.top.host $w.top.port \
1850 $w.top.idAuthentication $w.top.maximumRecordSize \
1851 $w.top.preferredMessageSize -side top -anchor e -pady 2
1853 entry-fields $w.top {description host port idAuthentication \
1854 maximumRecordSize preferredMessageSize} \
1855 {{Description:} {Host:} {Port:} {Id Authentication:} \
1856 {Maximum Record Size:} {Preferred Message Size:}} \
1857 [list protocol-setup-action $target $w] [list destroy $w]
1859 foreach sub {description host port idAuthentication \
1860 maximumRecordSize preferredMessageSize} {
1862 bind $w.top.$sub.entry <Control-a> [list add-database $target $w]
1863 bind $w.top.$sub.entry <Control-d> [list delete-database $target $w]
1865 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1866 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1867 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1868 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1869 $w.top.maximumRecordSize.entry insert 0 [lindex $profile($target) 4]
1870 $w.top.preferredMessageSize.entry insert 0 [lindex $profile($target) 5]
1871 set csRadioType [lindex $profile($target) 6]
1872 set RPNCheck [lindex $profile($target) 8]
1873 set CCLCheck [lindex $profile($target) 9]
1874 set ResultSetCheck [lindex $profile($target) 10]
1875 set protocolRadioType [lindex $profile($target) 11]
1876 if {$protocolRadioType == ""} {
1877 set protocolRadioType Z39
1881 pack $w.top.databases -side left -pady 2 -padx 2 -expand yes -fill both
1883 label $w.top.databases.label -text "Databases"
1884 button $w.top.databases.add -text Add \
1885 -command [list add-database $target $w]
1886 button $w.top.databases.delete -text Delete \
1887 -command [list delete-database $target $w]
1889 listbox $w.top.databases.list -geometry 14x6 \
1890 -yscrollcommand "$w.top.databases.scroll set"
1892 listbox $w.top.databases.list -width 14 -height 5\
1893 -yscrollcommand "$w.top.databases.scroll set"
1895 scrollbar $w.top.databases.scroll -orient vertical -border 1
1896 pack $w.top.databases.label -side top -fill x \
1898 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1900 pack $w.top.databases.list -side left -fill both -expand yes \
1902 pack $w.top.databases.scroll -side right -fill y \
1904 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1906 foreach b [lindex $profile($target) 7] {
1907 $w.top.databases.list insert end $b
1911 pack $w.top.cs-type -pady 2 -padx 2 -side top -fill x
1913 label $w.top.cs-type.label -text "Transport"
1914 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1915 -variable csRadioType -value tcpip
1916 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1917 -variable csRadioType -value mosi
1919 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1920 -padx 2 -side top -fill x
1923 pack $w.top.protocol -pady 2 -padx 2 -side top -fill x
1925 label $w.top.protocol.label -text "Protocol"
1926 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1927 -variable protocolRadioType -value Z39
1928 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1929 -variable protocolRadioType -value SR
1931 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1932 -padx 2 -side top -fill x
1935 pack $w.top.query -pady 2 -padx 2 -side top -fill x
1937 label $w.top.query.label -text "Query support"
1938 checkbutton $w.top.query.c1 -text "RPN query" -anchor w -variable RPNCheck
1939 checkbutton $w.top.query.c2 -text "CCL query" -anchor w -variable CCLCheck
1940 checkbutton $w.top.query.c3 -text "Result sets" -anchor w -variable ResultSetCheck
1942 pack $w.top.query.label -side top
1943 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
1944 -padx 2 -side top -fill x
1947 bottom-buttons $w [list {Ok} [list protocol-setup-action $target $w] \
1948 {Delete} [list protocol-setup-delete $target $w] \
1949 {Cancel} [list destroy $w]] 0
1952 proc database-select-action {} {
1953 set w .database-select.top
1955 foreach indx [$w.databases.list curselection] {
1956 lappend b [$w.databases.list get $indx]
1959 z39 databaseNames $b
1961 destroy .database-select
1964 proc database-select {} {
1965 set w .database-select
1970 set oldFocus [focus]
1975 frame $w.top.databases -relief ridge -border 2
1977 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
1979 label $w.top.databases.label -text "List"
1980 listbox $w.top.databases.list -width 20 -height 6 \
1981 -yscrollcommand "$w.top.databases.scroll set"
1982 scrollbar $w.top.databases.scroll -orient vertical -border 1
1983 pack $w.top.databases.label -side top -fill x \
1985 pack $w.top.databases.list -side left -fill both -expand yes \
1987 pack $w.top.databases.scroll -side right -fill y \
1989 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1991 foreach b [lindex $profile($hostid) 7] {
1992 $w.top.databases.list insert end $b
1994 top-down-ok-cancel $w {database-select-action} 1
1998 proc cascade-target-list {} {
2001 foreach sub [winfo children .top.target.m.clist] {
2004 .top.target.m.clist delete 0 last
2005 foreach n [lsort [array names profile]] {
2006 if {$n != "Default"} {
2007 set nl [lindex $profile($n) 12]
2008 if {[llength [lindex $profile($n) 7]] > 1} {
2009 .top.target.m.clist add cascade -label $n \
2010 -menu .top.target.m.clist.$nl
2011 menu .top.target.m.clist.$nl
2012 foreach b [lindex $profile($n) 7] {
2013 .top.target.m.clist.$nl add command -label $b \
2014 -command [list reopen-target $n $b]
2017 .top.target.m.clist add command -label $n \
2018 -command [list reopen-target $n {}]
2022 .top.target.m.slist delete 0 last
2023 foreach n [lsort [array names profile]] {
2024 if {$n != "Default"} {
2025 .top.target.m.slist add command -label $n \
2026 -command [list protocol-setup $n]
2031 proc query-select {i} {
2032 global queryButtonsFind
2033 global queryInfoFind
2037 set queryInfoFind [lindex $queryInfo $i]
2038 set queryButtonsFind [lindex $queryButtons $i]
2040 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2043 proc query-new-action {} {
2047 global settingsChanged
2049 set settingsChanged 1
2050 lappend queryTypes [.query-new.top.index.entry get]
2051 lappend queryButtons {}
2052 lappend queryInfo {}
2062 set oldFocus [focus]
2067 -side top -anchor e -pady 2
2068 entry-fields $w.top index \
2070 query-new-action {destroy .query-new}
2071 top-down-ok-cancel $w query-new-action 1
2075 proc query-delete-action {queryNo} {
2079 global settingsChanged
2081 set settingsChanged 1
2083 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
2084 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
2085 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
2086 destroy .query-delete
2090 proc query-delete {queryNo} {
2098 set n [lindex $queryTypes $queryNo]
2100 label $w.top.warning -bitmap warning
2101 message $w.top.quest -text "Are you sure you want to delete the \
2102 query type $n ?" -aspect 300
2103 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
2104 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
2105 {Cancel} [list destroy $w]] 1
2108 proc cascade-query-list {} {
2110 set w .top.options.m.query
2113 $w.slist delete 0 last
2114 foreach n $queryTypes {
2115 $w.slist add command -label $n -command [list query-setup $i]
2120 $w.clist delete 0 last
2121 foreach n $queryTypes {
2122 $w.clist add command -label $n -command [list query-select $i]
2126 $w.dlist delete 0 last
2127 foreach n $queryTypes {
2128 $w.dlist add command -label $n -command [list query-delete $i]
2133 proc save-geometry {} {
2134 global windowGeometry
2137 global displayFormat
2140 global elementSetNames
2142 set windowGeometry(.) [wm geometry .]
2144 if {[catch {set f [open ~/.clientrc.tcl w]}]} {
2147 puts $f "set hotTargets \{ $hotTargets \}"
2148 puts $f "set textWrap $textWrap"
2149 puts $f "set displayFormat $displayFormat"
2150 puts $f "set popupMarcdf $popupMarcdf"
2151 puts $f "set recordSyntax $recordSyntax"
2152 puts $f "set elementSetNames $elementSetNames"
2153 foreach n [array names windowGeometry] {
2154 puts -nonewline $f "set \{windowGeometry($n)\} \{"
2155 puts -nonewline $f $windowGeometry($n)
2161 proc save-settings {} {
2164 global settingsChanged
2169 if {![file writable "${libdir}/clientrc.tcl"]} {
2170 set a [alert "Cannot open ${libdir}/clientrc.tcl for writing. Do you \
2171 wish to save clientrc.tcl in the current directory instead?"]
2175 set f [open "clientrc.tcl" w]
2177 set f [open "${libdir}/clientrc.tcl" w]
2179 puts $f "# Setup file"
2181 foreach n [array names profile] {
2182 puts -nonewline $f "set \{profile($n)\} \{"
2183 puts -nonewline $f $profile($n)
2186 puts -nonewline $f "set queryTypes \{"
2187 puts -nonewline $f $queryTypes
2190 puts -nonewline $f "set queryButtons \{"
2191 puts -nonewline $f $queryButtons
2194 puts -nonewline $f "set queryInfo \{"
2195 puts -nonewline $f $queryInfo
2198 set settingsChanged 0
2207 set oldFocus [focus]
2211 label $w.top.warning -bitmap warning
2212 message $w.top.message -text $ask -aspect 300 \
2213 -font -Adobe-Times-Medium-R-Normal-*-180-*
2215 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
2218 top-down-ok-cancel $w {alert-action} 1
2223 proc alert-action {} {
2229 proc exit-action {} {
2230 global settingsChanged
2232 if {$settingsChanged} {
2233 set a [alert "you haven't saved your settings. Do you wish to save?"]
2242 proc listbuttonaction {w name h user i} {
2243 $w configure -text [lindex $name 0]
2244 $h [lindex $name 1] $user $i
2247 proc listbuttonx {button no names handle user} {
2248 if {[winfo exists $button]} {
2249 $button configure -text [lindex [lindex $names $no] 0]
2250 ${button}.m delete 0 last
2252 menubutton $button -text [lindex [lindex $names $no] 0] \
2253 -width 10 -menu ${button}.m -relief raised -border 1
2257 foreach name $names {
2258 ${button}.m add command -label [lindex $name 0] \
2259 -command [list listbuttonaction ${button} $name \
2265 proc listbutton {button no names} {
2266 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
2267 -relief raised -border 1
2269 foreach name $names {
2270 ${button}.m add command -label $name \
2271 -command [list ${button} configure -text $name]
2275 proc listbuttonv-action {button var names i} {
2278 set $var [lindex $names [expr $i+1]]
2279 $button configure -text [lindex $names $i]
2282 proc listbuttonv {button var names} {
2286 eval "set val $$var"
2287 set l [llength $names]
2288 for {set i 1} {$i < $l} {incr i 2} {
2289 if {$val == [lindex $names $i]} {
2291 set n [lindex $names $i]
2295 if {[winfo exists $button]} {
2296 $button configure -text $n
2299 menubutton $button -text $n -menu ${button}.m \
2300 -relief raised -border 1
2302 for {set i 0} {$i < $l} {incr i 2} {
2303 ${button}.m add command -label [lindex $names $i] \
2304 -command [list listbuttonv-action $button $var $names $i]
2308 proc query-add-index-action {queryNo} {
2312 global queryButtonsTmp
2314 set newI [.query-add-index.top.index.entry get]
2315 lappend queryInfoTmp [list $newI {}]
2316 $w.top.index.list insert end $newI
2317 destroy .query-add-index
2318 #destroy $w.top.lines
2319 #frame $w.top.lines -relief ridge -border 2
2320 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2321 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2324 proc query-add-line {queryNo} {
2328 global queryButtonsTmp
2330 lappend queryButtonsTmp {I 0}
2332 #destroy $w.top.lines
2333 #frame $w.top.lines -relief ridge -border 2
2334 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2335 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2338 proc query-del-line {queryNo} {
2342 global queryButtonsTmp
2344 set l [llength $queryButtonsTmp]
2349 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
2350 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2353 proc query-add-index {queryNo} {
2354 set w .query-add-index
2357 set oldFocus [focus]
2358 place-force $w .query-setup
2362 -side top -anchor e -pady 2
2363 entry-fields $w.top {index} \
2365 [list query-add-index-action $queryNo] [list destroy $w]
2366 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
2370 proc query-setup-action {queryNo} {
2373 global queryButtonsTmp
2375 global queryButtonsFind
2376 global queryInfoFind
2378 global settingsChanged
2380 set settingsChanged 1
2382 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
2384 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
2386 set queryInfoFind $queryInfoTmp
2387 set queryButtonsFind $queryButtonsTmp
2389 destroy .query-setup
2390 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2393 proc activate-e-index {value no i} {
2394 global queryButtonsTmp
2395 global queryIndexTmp
2397 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
2398 dputs $queryButtonsTmp
2399 set queryIndexTmp $i
2402 proc activate-index {value no i} {
2403 global queryButtonsFind
2405 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
2407 dputs "queryButtonsFind $queryButtonsFind"
2410 proc update-attr {} {
2412 listbuttonv $w.top.relation.b relationTmpValue\
2413 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
2414 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
2415 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
2416 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
2417 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
2418 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
2419 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
2420 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
2421 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
2422 {local-number} 107 {string} 108 {numeric string} 109}
2423 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2424 {Left} 2 {Left and right} 3 {No truncation} 100 \
2425 {Process #} 101 {Re-1} 102 {Re-2} 103}
2426 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2427 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2430 proc use-attr {init} {
2442 {BNB card number} 10
2443 {BGF(sic) number} 11
2445 {Dewey classification} 13
2446 {UDC classification} 14
2447 {Bliss classification} 15
2449 {NLM call number} 17
2450 {NAL call number} 18
2451 {MOS call number} 19
2452 {Local classification} 20
2453 {Subject heading} 21
2455 {BDI-index-subject} 23
2459 {LC-subject-heading} 27
2460 {RVM-subject-heading} 28
2461 {Local subject index} 29
2463 {Date of publication} 31
2464 {Date of acquisition} 32
2466 {Title-collective} 34
2469 {Title-added-title-page} 37
2473 {Title-other-variant} 41
2475 {Title-abbreviated} 43
2479 {Subject-subdivision} 47
2480 {Number-natl-bibliography} 48
2481 {Number-legal-deposit} 49
2482 {Number-govt-publication} 50
2483 {Number-publisher-for-music} 51
2485 {Number-local-call} 53
2487 {Code-geographic-area} 55
2488 {Code-institution} 56
2490 {Name-geographic} 58
2491 {Place-publication} 59
2493 {Microform-generation} 61
2500 {Author-name-personal} 1004
2501 {Author-name-corporate} 1005
2502 {Author-name-conference} 1006
2503 {Identifier-standard} 1007
2504 {Subject-LC-children's} 1008
2505 {Subject-name-personal} 1009
2507 {Date/time added to database} 1011
2508 {Date/time last modified} 1012
2509 {Authority/format identifier} 1013
2511 {Concept-reference} 1015
2513 {Server choice} 1017
2515 {Record source} 1019
2518 {Geographic class} 1022
2522 {Related periodical} 1026
2523 {Report number} 1027
2525 {Thematic number} 1030
2526 {Material type} 1031
2534 set l [llength $attr]
2539 for {set i 0} {$i < $l} {incr i} {
2540 $w.top.use.list insert end [lindex $attr $i]
2542 if {$useTmpValue == [lindex $attr $i]} {
2548 $w.top.use.list selection clear 0 end
2549 $w.top.use.list selection set $s $s
2551 $w.top.use.list select from $s
2552 $w.top.use.list select to $s
2558 $w.top.use.list yview $s
2560 set lno [lindex [$w.top.use.list curselection] 0]
2561 set i [expr $lno+$lno+1]
2562 set useTmpValue [lindex $attr $i]
2563 dputs "useTmpValue=$useTmpValue"
2567 proc index-setup-action {oldAttr queryNo indexNo} {
2568 set attr [lindex $oldAttr 0]
2571 global relationTmpValue
2572 global structureTmpValue
2573 global truncationTmpValue
2574 global completenessTmpValue
2575 global positionTmpValue
2580 dputs "index-setup-action"
2581 dputs "queryNo $queryNo"
2582 dputs "indexNo $indexNo"
2583 if {$useTmpValue > 0} {
2584 lappend attr "1=$useTmpValue"
2586 if {$relationTmpValue > 0} {
2587 lappend attr "2=$relationTmpValue"
2589 if {$positionTmpValue > 0} {
2590 lappend attr "3=$positionTmpValue"
2592 if {$structureTmpValue > 0} {
2593 lappend attr "4=$structureTmpValue"
2595 if {$truncationTmpValue > 0} {
2596 lappend attr "5=$truncationTmpValue"
2598 if {$completenessTmpValue > 0} {
2599 lappend attr "6=$completenessTmpValue"
2601 dputs "new attr $attr"
2602 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2603 destroy .index-setup
2606 proc index-setup {attr queryNo indexNo} {
2609 global relationTmpValue
2610 global structureTmpValue
2611 global truncationTmpValue
2612 global completenessTmpValue
2613 global positionTmpValue
2615 set relationTmpValue 0
2616 set truncationTmpValue 0
2617 set structureTmpValue 0
2618 set positionTmpValue 0
2619 set completenessTmpValue 0
2625 set n [lindex $attr 0]
2626 wm title $w "Index setup $n"
2630 set len [llength $attr]
2631 for {set i 1} {$i < $len} {incr i} {
2632 set q [lindex $attr $i]
2633 set l [string first = $q]
2635 set t [string range $q 0 [expr $l - 1]]
2636 set v [string range $q [expr $l + 1] end]
2639 { set useTmpValue $v }
2641 { set relationTmpValue $v }
2643 { set positionTmpValue $v }
2645 { set structureTmpValue $v }
2647 { set truncationTmpValue $v }
2649 { set completenessTmpValue $v }
2654 frame $w.top.use -relief ridge -border 2
2655 frame $w.top.relation -relief ridge -border 2
2656 frame $w.top.position -relief ridge -border 2
2657 frame $w.top.structure -relief ridge -border 2
2658 frame $w.top.truncation -relief ridge -border 2
2659 frame $w.top.completeness -relief ridge -border 2
2665 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2667 label $w.top.use.label -text "Use"
2669 listbox $w.top.use.list -width 26 \
2670 -yscrollcommand "$w.top.use.scroll set"
2672 listbox $w.top.use.list -geometry 26x10 \
2673 -yscrollcommand "$w.top.use.scroll set"
2675 scrollbar $w.top.use.scroll -orient vertical -border 1
2676 pack $w.top.use.label -side top -fill x \
2678 pack $w.top.use.list -side left -fill both -expand yes \
2680 pack $w.top.use.scroll -side right -fill y \
2682 $w.top.use.scroll config -command "$w.top.use.list yview"
2686 # Relation Attributes
2688 pack $w.top.relation -pady 6 -padx 6 -side top
2689 label $w.top.relation.label -text "Relation" -width 18
2691 pack $w.top.relation.label $w.top.relation.b -fill x
2693 # Position Attributes
2695 pack $w.top.position -pady 6 -padx 6 -side top
2696 label $w.top.position.label -text "Position" -width 18
2698 pack $w.top.position.label $w.top.position.b -fill x
2700 # Structure Attributes
2702 pack $w.top.structure -pady 6 -padx 6 -side top
2703 label $w.top.structure.label -text "Structure" -width 18
2705 pack $w.top.structure.label $w.top.structure.b -fill x
2707 # Truncation Attributes
2709 pack $w.top.truncation -pady 6 -padx 6 -side top
2710 label $w.top.truncation.label -text "Truncation" -width 18
2712 pack $w.top.truncation.label $w.top.truncation.b -fill x
2714 # Completeness Attributes
2716 pack $w.top.completeness -pady 6 -padx 6 -side top
2717 label $w.top.completeness.label -text "Completeness" -width 18
2719 pack $w.top.completeness.label $w.top.completeness.b -fill x
2722 bottom-buttons $w [list \
2723 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2724 {Cancel} [list destroy $w]] 0
2728 proc query-edit-index {queryNo} {
2732 set i [lindex [$w.top.index.list curselection] 0]
2736 set attr [lindex $queryInfoTmp $i]
2737 dputs "Editing no $i $attr"
2738 index-setup $attr $queryNo $i
2741 proc query-delete-index {queryNo} {
2743 global queryButtonsTmp
2746 set i [lindex [$w.top.index.list curselection] 0]
2750 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2751 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2752 $w.top.index.list delete $i
2755 proc query-setup {queryNo} {
2761 global queryButtonsTmp
2763 global queryIndexTmp
2766 set queryName [lindex $queryTypes $queryNo]
2767 set queryInfoTmp [lindex $queryInfo $queryNo]
2768 set queryButtonsTmp [lindex $queryButtons $queryNo]
2773 wm title $w "Query setup $queryName"
2777 frame $w.top.lines -relief ridge -border 2
2779 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2783 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2785 button $w.top.lines.add -text "Add" \
2786 -command [list query-add-line $queryNo]
2787 button $w.top.lines.del -text "Remove" \
2788 -command [list query-del-line $queryNo]
2790 pack $w.top.lines.del -fill x -side bottom
2791 pack $w.top.lines.add -fill x -pady 10 -side bottom
2795 frame $w.top.index -relief ridge -border 2
2796 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2798 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2799 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2800 -command [list $w.top.index.list yview]
2801 bind $w.top.index.list <Double-1> [list query-edit-index $queryNo]
2803 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2804 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2807 $w.top.index.list selection clear 0 end
2808 $w.top.index.list selection set 0 0
2810 $w.top.index.list select from 0
2811 $w.top.index.list select to 0
2814 foreach x $queryInfoTmp {
2815 $w.top.index.list insert end [lindex $x 0]
2819 bottom-buttons $w [list \
2820 Ok [list query-setup-action $queryNo] \
2821 Add [list query-add-index $queryNo] \
2822 Edit [list query-edit-index $queryNo] \
2823 Delete [list query-delete-index $queryNo] \
2824 Cancel [list destroy $w]] 0
2827 proc index-clear {} {
2828 global queryButtonsFind
2831 foreach b $queryButtonsFind {
2832 .lines.$i.e delete 0 end
2837 proc index-query {} {
2838 global queryButtonsFind
2839 global queryInfoFind
2844 foreach b $queryButtonsFind {
2845 set term [string trim [.lines.$i.e get]]
2847 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
2850 set len [string length $term]
2854 if {[string index $term 0] == ">"} {
2855 if {[string index $term 1] == "=" } {
2856 set term [string trim [string range $term 2 $len]]
2859 set term [string trim [string range $term 1 $len]]
2862 } elseif {[string index $term 0] == "<"} {
2863 if {[string index $term 1] == "=" } {
2864 set term [string trim [string range $term 2 $len]]
2866 } elseif {[string index $term 1] == ">"} {
2867 set term [string trim [string range $term 2 $len]]
2870 set term [string trim [string range $term 1 $len]]
2875 set len [string length $term]
2879 if {[string index $term $len] == "?"} {
2881 set term [string range $term 0 [expr $len - 1]]
2883 if {[string index $term 0] == "?"} {
2885 set term [string range $term 1 end]
2887 set term "\{${term}\}"
2888 if {$right && $left} {
2889 set term "@attr 5=3 ${term}"
2891 set term "@attr 5=1 ${term}"
2893 set term "@attr 5=2 ${term}"
2895 if {$relation != ""} {
2896 set term "@attr 2=${relation} ${term}"
2899 set term "@attr $a ${term}"
2902 set qs "@and ${qs} ${term}"
2913 proc index-focus-in {w i} {
2914 global curIndexEntry
2917 $w.$i configure -background red
2919 set curIndexEntry $i
2922 proc index-lines {w realOp buttonInfo queryInfo handle} {
2924 foreach b $buttonInfo {
2925 if {! [winfo exists $w.$i]} {
2927 frame $w.$i -border 0
2929 frame $w.$i -background white -border 1
2932 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
2935 if {! [winfo exists $w.$i.e]} {
2936 entry $w.$i.e -width 32 -relief sunken -border 1
2937 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
2938 bind $w.$i.e <FocusOut> [list $w.$i configure \
2940 pack $w.$i.l -side left
2941 pack $w.$i.e -side left -fill x -expand yes
2942 pack $w.$i -side top -fill x -padx 2 -pady 2
2944 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2945 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2947 bind $w.$i.e <Return> {search-request 0}
2950 pack $w.$i.l -side left
2951 pack $w.$i -side top -fill x -padx 2 -pady 2
2956 while {[winfo exists $w.$j]} {
2968 bind $w.$j.e <Tab> "focus $w.$k.e"
2974 bind $w.$i.e <Tab> "focus $w.0.e"
2980 proc search-fields {w buttondefs} {
2982 foreach buttondef $buttondefs {
2983 frame $w.$i -background white
2985 listbutton $w.$i.l 0 $buttondef
2986 entry $w.$i.e -width 32 -relief sunken
2988 pack $w.$i.l -side left
2989 pack $w.$i.e -side left -fill x -expand yes
2991 pack $w.$i -side top -fill x -padx 2 -pady 2
2993 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2994 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
3002 bind $w.$j.e <Tab> "focus $w.$k.e \n
3003 $w.$k configure -background red \n
3004 $w.$j configure -background white"
3007 bind $w.$i.e <Tab> "focus $w.0.e \n
3008 $w.0 configure -background red \n
3009 $w.$i configure -background white"
3011 $w.0 configure -background red
3014 if {[info exists windowGeometry(.)]} {
3015 set g $windowGeometry(.)
3023 frame .top -border 1 -relief raised
3024 frame .lines -border 1 -relief raised
3025 frame .mid -border 1 -relief raised
3026 frame .data -border 1 -relief raised
3027 frame .bot -border 1 -relief raised
3028 pack .top .lines .mid -side top -fill x
3029 pack .data -side top -fill both -expand yes
3032 menubutton .top.file -text "File" -menu .top.file.m
3034 .top.file.m add command -label "Save settings" -command {save-settings}
3035 .top.file.m add separator
3036 .top.file.m add command -label "Exit" -command {exit-action}
3038 menubutton .top.target -text "Target" -menu .top.target.m
3040 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
3041 .top.target.m add command -label "Disconnect" -command {close-target}
3042 .top.target.m add command -label "About" -command {about-target}
3043 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
3044 .top.target.m add command -label "Setup new" -command {define-target-dialog}
3045 .top.target.m add separator
3046 set-target-hotlist 0
3048 configure-disable-e .top.target.m 1
3049 configure-disable-e .top.target.m 2
3051 menu .top.target.m.clist
3052 menu .top.target.m.slist
3055 menubutton .top.service -text "Service" -menu .top.service.m
3057 .top.service.m add command -label "Database" -command {database-select}
3058 .top.service.m add cascade -label "Present" -menu .top.service.m.present
3059 menu .top.service.m.present
3060 .top.service.m.present add command -label "10 More" \
3061 -command [list present-more 10]
3062 .top.service.m.present add command -label "All" \
3063 -command [list present-more {}]
3064 .top.service.m add command -label "Search" -command {search-request 0}
3065 .top.service.m add command -label "Scan" -command {scan-request}
3067 .top.service configure -state disabled
3069 menubutton .top.rset -text "Set" -menu .top.rset.m
3071 .top.rset.m add command -label "Load" -command {load-set}
3072 .top.rset.m add separator
3074 menubutton .top.options -text "Options" -menu .top.options.m
3076 .top.options.m add cascade -label "Query" -menu .top.options.m.query
3077 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
3078 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
3079 .top.options.m add cascade -label "Syntax" -menu .top.options.m.syntax
3080 .top.options.m add cascade -label "Elements" -menu .top.options.m.elements
3082 menu .top.options.m.query
3083 .top.options.m.query add cascade -label "Select" \
3084 -menu .top.options.m.query.clist
3085 .top.options.m.query add cascade -label "Edit" \
3086 -menu .top.options.m.query.slist
3087 .top.options.m.query add command -label "New" \
3088 -command {query-new}
3089 .top.options.m.query add cascade -label "Delete" \
3090 -menu .top.options.m.query.dlist
3092 menu .top.options.m.query.slist
3093 menu .top.options.m.query.clist
3094 menu .top.options.m.query.dlist
3097 menu .top.options.m.formats
3099 foreach f $displayFormats {
3100 .top.options.m.formats add radiobutton -label $f -value $i \
3101 -command [list set-display-format $i] -variable displayFormat
3105 menu .top.options.m.wrap
3106 .top.options.m.wrap add radiobutton -label "Character" \
3107 -value char -variable textWrap -command {set-wrap char}
3108 .top.options.m.wrap add radiobutton -label "Word" \
3109 -value word -variable textWrap -command {set-wrap word}
3110 .top.options.m.wrap add radiobutton -label "None" \
3111 -value none -variable textWrap -command {set-wrap none}
3113 menu .top.options.m.syntax
3114 .top.options.m.syntax add radiobutton -label "None" \
3115 -value None -variable recordSyntax
3116 .top.options.m.syntax add separator
3117 .top.options.m.syntax add radiobutton -label "USMARC" \
3118 -value USMARC -variable recordSyntax
3119 .top.options.m.syntax add radiobutton -label "UNIMARC" \
3120 -value UNIMARC -variable recordSyntax
3121 .top.options.m.syntax add radiobutton -label "UKMARC" \
3122 -value UKMARC -variable recordSyntax
3123 .top.options.m.syntax add radiobutton -label "DANMARC" \
3124 -value DANMARC -variable recordSyntax
3125 .top.options.m.syntax add radiobutton -label "FINMARC" \
3126 -value FINMARC -variable recordSyntax
3127 .top.options.m.syntax add radiobutton -label "NORMARC" \
3128 -value NORMARC -variable recordSyntax
3129 .top.options.m.syntax add radiobutton -label "PICAMARC" \
3130 -value PICAMARC -variable recordSyntax
3131 .top.options.m.syntax add separator
3132 .top.options.m.syntax add radiobutton -label "SUTRS" \
3133 -value SUTRS -variable recordSyntax
3134 .top.options.m.syntax add separator
3135 .top.options.m.syntax add radiobutton -label "GRS1" \
3136 -value GRS1 -variable recordSyntax
3138 menu .top.options.m.elements
3139 .top.options.m.elements add radiobutton -label "Unspecified" \
3140 -value None -variable elementSetNames
3141 .top.options.m.elements add radiobutton -label "Full" \
3142 -value F -variable elementSetNames
3143 .top.options.m.elements add radiobutton -label "Brief" \
3144 -value B -variable elementSetNames
3146 menubutton .top.help -text "Help" -menu .top.help.m
3149 .top.help.m add command -label "Help on help" \
3150 -command {tkerror "Help on help not available. Sorry"}
3151 .top.help.m add command -label "About" -command {about-origin}
3153 pack .top.file .top.target .top.service .top.rset .top.options -side left
3154 pack .top.help -side right
3156 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
3158 button .mid.search -text Search -command {search-request 0} \
3160 button .mid.scan -text Scan \
3161 -command scan-request -state disabled
3162 button .mid.present -text {Present} -command [list present-more 10] \
3165 button .mid.clear -text Clear -command index-clear
3166 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
3169 text .data.record -height 2 -width 20 -wrap none \
3170 -yscrollcommand [list .data.scroll set] -wrap $textWrap
3171 scrollbar .data.scroll -command [list .data.record yview]
3173 .data.record configure -takefocus 0
3174 .data.scroll configure -takefocus 0
3176 pack .data.scroll -side right -fill y
3177 pack .data.record -expand yes -fill both
3181 .data.record tag configure marc-tag -foreground blue
3182 .data.record tag configure marc-id -foreground red
3184 .data.record tag configure marc-tag -foreground black
3185 .data.record tag configure marc-id -foreground black
3187 .data.record tag configure marc-data -foreground black
3188 .data.record tag configure marc-head \
3189 -font -Adobe-Times-Bold-R-Normal-*-140-* \
3190 -foreground brown -relief raised -borderwidth 1
3191 .data.record tag configure marc-small-head -foreground brown
3192 .data.record tag configure marc-pref \
3193 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3195 .data.record tag configure marc-text \
3196 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3198 .data.record tag configure marc-it \
3199 -font -Adobe-Times-Medium-I-Normal-*-140-* \
3202 button .bot.logo -bitmap @${libdir}/bitmaps/book1 -command cancel-operation
3204 .bot.logo configure -takefocus 0
3207 pack .bot.a -side left -fill x
3208 pack .bot.logo -side right -padx 2 -pady 2 -ipadx 1
3210 message .bot.a.target -text "" -aspect 1000 -border 1
3212 label .bot.a.status -text "Not connected" -width 15 -relief \
3213 sunken -anchor w -border 1
3214 label .bot.a.set -text "" -width 5 -relief \
3215 sunken -anchor w -border 1
3216 label .bot.a.message -text "" -width 15 -relief \
3217 sunken -anchor w -border 1
3219 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
3220 pack .bot.a.status .bot.a.set .bot.a.message \
3221 -side left -padx 2 -pady 2 -ipadx 1 -ipady 1
3223 if {[catch {ir z39}]} {
3224 set e [info sharedlibextension]
3225 puts -nonewline "Loading irtcl$e ..."
3230 z39 largeSetLowerBound 20
3231 z39 smallSetUpperBound 2
3232 z39 mediumSetPresentNumber 2