1 # IR toolkit for tcl/tk
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
7 # Revision 1.79 1995-10-18 16:42:37 adam
8 # New settings: smallSetElementSetNames and mediumSetElementSetNames.
10 # Revision 1.78 1995/10/18 15:45:36 quinn
11 # *** empty log message ***
13 # Revision 1.77 1995/10/18 15:37:46 adam
16 # Revision 1.76 1995/10/18 15:15:20 adam
19 # Revision 1.75 1995/10/17 14:18:05 adam
20 # Minor changes in presentation formats.
22 # Revision 1.74 1995/10/17 12:18:57 adam
23 # Bug fix: when target connection closed, the connection was not
24 # properly reestablished.
26 # Revision 1.73 1995/10/17 10:58:06 adam
27 # More work on presentation formats.
29 # Revision 1.72 1995/10/16 17:00:52 adam
30 # New setting: elementSetNames.
31 # Various client improvements. Medium presentation format looks better.
33 # Revision 1.71 1995/10/13 15:35:27 adam
34 # Relational operators may be used in search entries - changes
35 # in proc index-query.
37 # Revision 1.70 1995/10/12 14:46:52 adam
38 # Better record popup windows. Next/prev buttons in popup record windows.
39 # The record position in the raw format is much more visible.
41 # Revision 1.69 1995/09/21 13:42:54 adam
44 # Revision 1.68 1995/09/21 13:11:49 adam
45 # Support of dynamic loading.
46 # Test script uses load command if necessary.
48 # Revision 1.67 1995/09/20 14:35:19 adam
51 # Revision 1.66 1995/08/29 15:30:13 adam
52 # Work on GRS records.
54 # Revision 1.65 1995/08/24 15:39:09 adam
57 # Revision 1.64 1995/08/24 15:33:02 adam
60 # Revision 1.63 1995/08/04 13:20:48 adam
61 # Buttons at the bottom are slightly smaller.
63 # Revision 1.62 1995/08/04 11:32:37 adam
64 # More work on output queue. Memory related routines moved
67 # Revision 1.61 1995/07/20 08:09:39 adam
68 # client.tcl: Targets removed from hotTargets list when targets
69 # are removed/modified.
70 # ir-tcl.c: More work on triggerResourceControl.
72 # Revision 1.60 1995/06/30 16:30:19 adam
75 # Revision 1.59 1995/06/29 14:06:25 adam
76 # Another bug in install fixed. Configure searches for more versions of yaz.
78 # Revision 1.58 1995/06/29 12:34:06 adam
79 # IrTcl now works with both tk4.0b4/tcl7.4b4 and tk3.6/tcl7.3
81 # Revision 1.57 1995/06/29 09:20:30 adam
82 # Target entries in cascade menus are sorted.
84 # Revision 1.56 1995/06/27 19:03:48 adam
85 # Bug fix in do_present in ir-tcl.c: p->set_child member weren't set.
86 # nextResultSetPosition used instead of setOffset.
88 # Revision 1.55 1995/06/27 17:10:37 adam
89 # Bug fix: install procedure didn't work on some systems.
90 # Error turned up when clientrc.tcl was't present.
92 # Revision 1.54 1995/06/27 14:41:03 adam
93 # Bug fix in search-response. Didn't always observe non-surrogate diagnostics.
95 # Revision 1.53 1995/06/26 12:40:09 adam
96 # Client defines its own tkerror.
97 # User may specify 'no preferredRecordSyntax'.
99 # Revision 1.52 1995/06/22 13:14:59 adam
100 # Feature: SUTRS. Setting getSutrs implemented.
101 # Work on display formats.
102 # Preferred record syntax can be set by the user.
104 # Revision 1.51 1995/06/21 11:11:00 adam
105 # Bug fix: libdir undefined in about-origin.
107 # Revision 1.50 1995/06/21 11:04:48 adam
108 # Uses GNU autoconf 2.3.
109 # Install procedure implemented.
110 # boook bitmaps moved to sub directory bitmaps.
112 # Revision 1.49 1995/06/20 14:16:42 adam
113 # More work on cancel mechanism.
115 # Revision 1.48 1995/06/20 08:07:23 adam
116 # New setting: failInfo.
117 # Working on better cancel mechanism.
119 # Revision 1.47 1995/06/19 14:05:29 adam
120 # Bug fix: asked for SUTRS.
122 # Revision 1.46 1995/06/19 13:06:06 adam
123 # New define: IR_TCL_VERSION.
125 # Revision 1.45 1995/06/19 08:08:44 adam
126 # client.tcl: hotTargets now contain both database and target name.
127 # ir-tcl.c: setting protocol edited. Errors in callbacks are logged
128 # by logf(LOG_WARN, ...) calls.
130 # Revision 1.44 1995/06/16 14:55:18 adam
131 # Book logo mirrored.
133 # Revision 1.43 1995/06/16 14:41:05 adam
134 # Scan line entries can be copied to a search entry.
136 # Revision 1.42 1995/06/16 12:28:13 adam
137 # Implemented preferredRecordSyntax.
138 # Minor changes in diagnostic handling.
139 # Record list deleted when connection closes.
141 # Revision 1.41 1995/06/14 15:07:59 adam
142 # Bug fix in cascade-target-list. Uses yaz-version.h.
144 # Revision 1.40 1995/06/14 13:37:17 adam
145 # Setting recordType implemented.
146 # Setting implementationVersion implemented.
147 # Settings implementationId / implementationName edited.
149 # Revision 1.39 1995/06/14 12:16:22 adam
150 # hotTargets, textWrap and displayFormat saved in clientg.tcl.
152 # Revision 1.38 1995/06/14 07:22:45 adam
153 # Target definitions can be deleted.
154 # Listbox used in the query definition dialog.
156 # Revision 1.37 1995/06/13 14:37:59 adam
157 # Work on query setup.
158 # Better about origin/target.
159 # Better presentation formats.
161 # Revision 1.36 1995/06/13 07:42:14 adam
162 # Bindings removed from text widgets.
164 # Revision 1.35 1995/06/12 15:17:31 adam
165 # Text widget used in main window (instead of listbox) to support
166 # better presentation formats.
168 # Revision 1.34 1995/06/12 07:59:07 adam
169 # More work on geometry handling.
171 # Revision 1.33 1995/06/09 11:17:35 adam
172 # Start work on geometry management.
174 # Revision 1.32 1995/06/07 09:16:37 adam
175 # New presentation format.
177 # Revision 1.31 1995/06/06 16:31:09 adam
178 # Bug fix: target names couldn't contain blanks.
181 # Revision 1.30 1995/06/06 11:35:41 adam
182 # Work on scan. Display of old sets.
184 # Revision 1.29 1995/06/05 14:11:18 adam
185 # Bug fix in present-more.
187 # Revision 1.28 1995/06/02 14:52:13 adam
188 # Minor changes really.
190 # Revision 1.27 1995/06/02 14:29:42 adam
191 # Work on scan interface - up/down buttons.
193 # Revision 1.26 1995/06/01 16:36:46 adam
194 # About buttons. Minor bug fixes.
196 # Revision 1.25 1995/05/31 13:09:57 adam
197 # Client searches/presents may be interrupted.
198 # New moving book-logo.
200 # Revision 1.24 1995/05/31 08:36:24 adam
201 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
202 # New method: referenceId. More work on scan.
204 # Revision 1.23 1995/05/29 10:33:41 adam
205 # README and rename of startup script.
207 # Revision 1.22 1995/05/26 11:44:09 adam
208 # Bugs fixed. More work on MARC utilities and queries. Test
209 # client is up-to-date again.
211 # Revision 1.21 1995/05/11 15:34:46 adam
212 # Scan request changed a bit. This version works with RLG.
214 # Revision 1.20 1995/04/21 16:31:57 adam
215 # New radiobutton: protocol (z39v2/SR).
217 # Revision 1.19 1995/04/18 16:11:50 adam
218 # First version of graphical Scan. Some work on query-by-form.
220 # Revision 1.18 1995/04/10 10:50:22 adam
221 # Result-set name defaults to suffix of ir-set name.
222 # Started working on scan. Not finished at this point.
224 # Revision 1.17 1995/03/31 09:34:57 adam
225 # Search-button disabled when there is no connection.
227 # Revision 1.16 1995/03/31 08:56:36 adam
228 # New button "Search".
230 # Revision 1.15 1995/03/28 12:45:22 adam
231 # New ir method failback: called on disconnect/protocol error.
232 # New ir set/get method: protocol: SR / Z3950.
233 # Simple popup and disconnect when failback is invoked.
235 # Revision 1.14 1995/03/22 16:07:55 adam
238 # Revision 1.13 1995/03/21 17:27:26 adam
239 # Short-hand keys in setup.
241 # Revision 1.12 1995/03/21 13:41:03 adam
242 # Comstack cs_create not used too often. Non-blocking connect.
244 # Revision 1.11 1995/03/21 10:39:06 adam
245 # Diagnostic error message displayed with tkerror.
247 # Revision 1.10 1995/03/20 15:24:06 adam
248 # Diagnostic records saved on searchResponse.
250 # Revision 1.9 1995/03/17 18:26:16 adam
251 # Non-blocking i/o used now. Database names popup as cascade items.
253 # Revision 1.8 1995/03/17 15:45:00 adam
254 # Improved target/database setup.
256 # Revision 1.7 1995/03/16 17:54:03 adam
257 # Minor changes really.
259 # Revision 1.6 1995/03/15 19:10:20 adam
260 # Database setup in protocol-setup (rather target setup).
262 # Revision 1.5 1995/03/15 13:59:23 adam
265 # Revision 1.4 1995/03/14 17:32:29 adam
266 # Presentation of full Marc record in popup window.
268 # Revision 1.3 1995/03/12 19:31:52 adam
269 # Pattern matching implemented when retrieving MARC records. More
270 # diagnostic functions.
272 # Revision 1.2 1995/03/10 18:00:15 adam
273 # Actual presentation in line-by-line format. RPN query support.
275 # Revision 1.1 1995/03/09 16:15:07 adam
276 # First presentRequest attempts. Hot-target list.
280 if {$tk_version == "3.6"} {
291 proc configure-enable-e {w n} {
293 $w entryconfigure $n -state normal
295 proc configure-disable-e {w n} {
297 $w entryconfigure $n -state disabled
299 set noFocus [list -takefocus 0]
301 proc configure-enable-e {w n} {
304 proc configure-disable-e {w n} {
311 if {[tk colormodel .] == "color"} {
321 if {[file readable bitmaps/book2]} {
324 if {! [file readable ${libdir}/bitmaps/book2]} {
325 puts "Cannot locate system files in ${libdir}. You must either run this"
326 puts "program from the source directory root of ir-tcl or you must assure"
327 puts "that it is installed - normally in /usr/local/lib/irtcl"
335 set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} Z39 1}
337 set settingsChanged 0
345 set recordSyntax None
346 set elementSetNames None
349 set queryTypes {Simple}
350 set queryButtons { { {I 0} {I 1} {I 2} } }
351 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
352 {Subject {1=21}} {Any {1=1016}} } }
361 if {[winfo exists $w]} {
370 label $w.top.b -bitmap error
371 message $w.top.t -aspect 300 -text "Error: $err" \
372 -font -Adobe-Helvetica-Bold-R-Normal-*-180-*
373 pack $w.top.b $w.top.t -side left -padx 10 -pady 10
375 bottom-buttons $w [list {Close} [list destroy $w]] 1
378 proc read-formats {} {
379 global displayFormats
381 if {[catch {set formats [glob -nocomplain ${libdir}/formats/*.tcl]}]} {
382 set formats ./formats/raw.tcl
385 if {[file readable $f]} {
387 set l [string length $f]
388 set f [string range $f [string length "${libdir}/formats/"] \
390 lappend displayFormats $f
399 .data.record configure -wrap $m
406 proc set-display-format {f} {
416 .bot.a.status configure -text "Reformatting"
419 add-title-lines -1 10000 1
422 proc initBindings {} {
425 bind $w <Double-1> {}
426 bind $w <Triple-1> {}
427 bind $w <B1-Motion> {}
429 bind $w <Shift-B1-Motion> {}
431 bind $w <B2-Motion> {}
432 bind $w <Any-KeyPress> {}
434 bind $w <BackSpace> {}
436 bind $w <Control-h> {}
437 bind $w <Control-d> {}
438 bind $w <Control-v> {}
441 bind $w <B1-Motion> {}
442 bind $w <Shift-B1-Motion> {}
447 proc post-menu {wbutton wmenu} {
450 $wmenu post [winfo rootx $wbutton] \
451 [expr [winfo rooty $wbutton]+[winfo height $wbutton]]
456 global windowGeometry
457 set windowGeometry($w) [wm geometry $w]
460 global windowGeometry
463 if {[info exists windowGeometry($w)]} {
464 set g $windowGeometry($w)
469 bind $w <Destroy> [list destroyGW $w]
472 if {[file readable "clientrc.tcl"]} {
473 source "clientrc.tcl"
475 if {[file readable "${libdir}/clientrc.tcl"]} {
476 source "${libdir}/clientrc.tcl"
480 if {[file readable "~/.clientrc.tcl"]} {
481 source "~/.clientrc.tcl"
484 set queryButtonsFind [lindex $queryButtons 0]
485 set queryInfoFind [lindex $queryInfo 0]
487 proc top-down-window {w} {
488 frame $w.top -relief raised -border 1
489 frame $w.bot -relief raised -border 1
491 pack $w.top -side top -fill both -expand yes
492 pack $w.bot -fill both
495 proc top-down-ok-cancel {w ok-action g} {
496 frame $w.bot.left -relief sunken -border 1
497 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 1 -pady 1
498 button $w.bot.left.ok -width 4 -text {Ok} \
499 -command ${ok-action}
500 pack $w.bot.left.ok -expand yes -ipadx 1 -ipady 1 -padx 2 -pady 2
501 button $w.bot.cancel -width 5 -text {Cancel} \
502 -command [list destroy $w]
503 pack $w.bot.cancel -side left -expand yes
511 proc bottom-buttons {w buttonList g} {
513 set l [llength $buttonList]
515 frame $w.bot.$i -relief sunken -border 1
516 pack $w.bot.$i -side left -expand yes -padx 2 -pady 2
517 button $w.bot.$i.ok -text [lindex $buttonList $i] \
518 -command [lindex $buttonList [expr $i+1]]
519 pack $w.bot.$i.ok -expand yes -padx 2 -pady 2 -side left
523 button $w.bot.$i -text [lindex $buttonList $i] \
524 -command [lindex $buttonList [expr $i+1]]
525 pack $w.bot.$i -expand yes -padx 2 -pady 2 -side left
535 proc cancel-operation {} {
543 show-status Cancel 0 1
547 proc show-target {target base} {
551 .bot.a.target configure -text ""
555 .bot.a.target configure -text "$target"
557 .bot.a.target configure -text "$target - $base"
561 proc show-logo {v1} {
570 .bot.logo configure -bitmap @${libdir}/bitmaps/book${v1}
571 after 140 [list show-logo $v1]
575 .bot.logo configure -bitmap @${libdir}/bitmaps/book1
584 proc show-status {status b sb} {
591 .bot.a.status configure -text "$status"
593 if {$busy == 0} {set busy 1}
601 .top.service configure -state normal
602 .mid.search configure -state normal
604 .mid.scan configure -state normal
607 configure-disable-e .top.service.m 1
608 } elseif {[z39.$setNo nextResultSetPosition] > 0 &&
609 [z39.$setNo nextResultSetPosition] <= [z39.$setNo resultCount]} {
610 configure-enable-e .top.service.m 1
611 .mid.present configure -state normal
613 configure-disable-e .top.service.m 1
614 .mid.present configure -state disabled
616 if {[winfo exists .scan-window]} {
617 .scan-window.bot.2 configure -state normal
618 .scan-window.bot.4 configure -state normal
621 .top.service configure -state disabled
622 .mid.search configure -state disabled
623 .mid.scan configure -state disabled
624 .mid.present configure -state disabled
626 if {[winfo exists .scan-window]} {
627 .scan-window.bot.2 configure -state disabled
628 .scan-window.bot.4 configure -state disabled
633 proc show-message {msg} {
634 .bot.a.message configure -text "$msg"
637 proc insertWithTags {w text args} {
638 set start [$w index insert]
639 $w insert insert $text
640 foreach tag [$w tag names $start] {
641 $w tag remove $tag $start insert
644 $w tag add $i $start insert
648 proc popup-license {} {
653 wm title $w "License"
659 text $w.top.t -width 80 -height 10 -wrap word \
660 -yscrollcommand [list $w.top.s set]
661 scrollbar $w.top.s -command [list $w.top.t yview]
663 pack $w.top.s -side right -fill y
664 pack $w.top.t -expand yes -fill both
666 if {[file readable "${libdir}/LICENSE"]} {
667 set f [open "${libdir}/LICENSE" r]
668 while {[gets $f buf] != -1} {
669 $w.top.t insert end $buf
670 $w.top.t insert end "\n"
674 bottom-buttons $w [list {Close} [list destroy $w]] 1
677 proc about-target {} {
678 set w .about-target-w
683 wm title $w "About target"
687 frame $w.top.a -relief ridge -border 2
688 frame $w.top.p -relief ridge -border 2
690 pack $w.top.a $w.top.p -side top -fill x
692 label $w.top.a.about -text "About"
693 label $w.top.a.irtcl -text $hostid \
694 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
695 pack $w.top.a.about $w.top.a.irtcl -side top
697 set i [z39 targetImplementationName]
698 label $w.top.p.in -text "Implementation name: $i"
699 set i [z39 targetImplementationId]
700 label $w.top.p.ii -text "Implementation id: $i"
701 set i [z39 targetImplementationVersion]
702 label $w.top.p.iv -text "Implementation version: $i"
704 label $w.top.p.op -text "Protocol options: $i"
706 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
708 bottom-buttons $w [list {Close} [list destroy $w]] 1
711 proc about-origin-logo {n} {
713 set w .about-origin-w
714 if {![winfo exists $w]} {
721 $w.top.a.logo configure -bitmap @${libdir}/bitmaps/book$n
722 after 140 [list about-origin-logo $n]
725 proc about-origin {} {
726 set w .about-origin-w
730 if {[winfo exists $w]} {
735 wm title $w "About IrTcl"
739 frame $w.top.a -relief ridge -border 2
740 frame $w.top.p -relief ridge -border 2
742 pack $w.top.a $w.top.p -side top -fill x
744 label $w.top.a.irtcl -text "IrTcl" \
745 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
746 label $w.top.a.logo -bitmap @${libdir}/bitmaps/book1
747 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
750 catch {set i [z39 implementationName]}
751 label $w.top.p.in -text "Implementation name: $i"
752 catch {set i [z39 implementationId]}
753 label $w.top.p.ii -text "Implementation id: $i"
754 catch {set i [z39 implementationVersion]}
755 label $w.top.p.iv -text "Implementation version: $i"
757 label $w.top.p.tk -text "Tk version: $i"
759 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.tk -side top -anchor nw
762 bottom-buttons $w [list {Close} [list destroy $w] \
763 {License} [list popup-license]] 0
766 proc popup-marc {sno no b df} {
767 global displayFormats
770 if {[z39.$sno type $no] != "DB"} {
775 while {[winfo exists .full-marc$b]} {
781 if {![winfo exists $w]} {
786 frame $w.top -relief raised -border 1
787 frame $w.bot -relief raised -border 1
789 pack $w.top -side top -fill both -expand yes
790 pack $w.bot -fill both
792 text $w.top.record -width 60 -height 5 -wrap word \
793 -yscrollcommand [list $w.top.s set]
794 scrollbar $w.top.s -command [list $w.top.record yview]
798 $w.top.record tag configure marc-tag -foreground blue
799 $w.top.record tag configure marc-id -foreground red
801 $w.top.record tag configure marc-tag -foreground black
802 $w.top.record tag configure marc-id -foreground black
804 $w.top.record tag configure marc-data -foreground black
805 $w.top.record tag configure marc-head \
806 -font -Adobe-Times-Medium-R-Normal-*-180-* \
807 -background black -foreground white
809 $w.top.record tag configure marc-pref \
810 -font -Adobe-Times-Medium-R-Normal-*-180-* \
812 $w.top.record tag configure marc-text \
813 -font -Adobe-Times-Medium-R-Normal-*-180-* \
815 $w.top.record tag configure marc-it \
816 -font -Adobe-Times-Medium-I-Normal-*-180-* \
819 pack $w.top.s -side right -fill y
820 pack $w.top.record -expand yes -fill both
822 bottom-buttons $w [list \
823 {Close} [list destroy $w] \
827 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m \
829 menu $w.bot.formats.m
830 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 \
831 -padx 3 -pady 3 -side left
833 $w.bot.formats.m delete 0 last
836 foreach f $displayFormats {
837 $w.bot.formats.m add radiobutton -label $f \
838 -variable popupMarcdf -value $i \
839 -command [list popup-marc $sno $no $b 0]
842 $w.top.record delete 0.0 end
843 set recordType [z39.$sno recordType $no]
844 wm title $w "$recordType record #$no"
846 $w.bot.2 configure -command \
847 [list popup-marc $sno [expr $no-1] $b $df]
848 $w.bot.4 configure -command \
849 [list popup-marc $sno [expr $no+1] $b $df]
851 $w.bot.2 configure -state disabled
853 $w.bot.2 configure -state normal
855 if {[z39.$sno type [expr $no+1]] != "DB"} {
856 $w.bot.4 configure -state disabled
858 $w.bot.4 configure -state normal
860 $w.bot.6 configure -command [list popup-marc $sno $no -1 0]
861 set ffunc [lindex $displayFormats $df]
862 set ffunc "display-$ffunc"
864 $ffunc $sno $no $w.top.record 0
867 proc update-target-hotlist {target base} {
870 set olen [llength $hotTargets]
872 foreach e $hotTargets {
873 if {$target == [lindex $e 0] && $base == [lindex $e 1]} {
874 set hotTargets [lreplace $hotTargets $i $i]
879 set hotTargets [linsert $hotTargets 0 [list $target $base]]
880 set-target-hotlist $olen
883 proc delete-target-hotlist {target} {
886 set olen [llength $hotTargets]
888 foreach e $hotTargets {
889 if {$target == [lindex $e 0]} {
890 set hotTargets [lreplace $hotTargets $i $i]
894 set-target-hotlist $olen
897 proc set-target-hotlist {olen} {
902 .top.target.m delete 7 [expr 7+$olen]
904 .top.target.m delete 6 [expr 6+$olen]
908 foreach e $hotTargets {
909 set target [lindex $e 0]
910 set base [lindex $e 1]
912 .top.target.m add command -label "$i $target" -command \
913 [list reopen-target $target {}]
915 .top.target.m add command -label "$i $target - $base" -command \
916 [list reopen-target $target $base]
925 proc reopen-target {target base} {
927 open-target $target $base
928 update-target-hotlist $target $base
931 proc define-target-action {} {
934 set target [.target-define.top.target.entry get]
938 foreach n [array names profile] {
944 set seq [lindex $profile(Default) 12]
946 set profile($target) $profile(Default)
947 set profile(Default) [lreplace $profile(Default) 12 12 [incr seq]]
949 protocol-setup $target
950 destroy .target-define
953 proc fail-response {target} {
954 set c [lindex [z39 failInfo] 0]
955 set m [lindex [z39 failInfo] 1]
960 proc connect-response {target base} {
961 dputs "connect-response"
962 show-target $target $base
966 proc open-target {target base} {
971 z39 comstack [lindex $profile($target) 6]
972 z39 protocol [lindex $profile($target) 11]
973 z39 idAuthentication [lindex $profile($target) 3]
974 z39 maximumRecordSize [lindex $profile($target) 4]
975 z39 preferredMessageSize [lindex $profile($target) 5]
976 dputs "maximumRecordSize="
977 dputs [z39 maximumRecordSize]
978 dputs "preferredMessageSize="
979 dputs [z39 preferredMessageSize]
980 show-status Connecting 1 0
982 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
984 z39 databaseNames $base
986 z39 failback [list fail-response $target]
987 z39 callback [list connect-response $target $base]
990 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
993 tkerror $errorMessage
994 show-status "Not connected" 0 {}
998 configure-disable-e .top.target.m 0
999 configure-enable-e .top.target.m 1
1000 configure-enable-e .top.target.m 2
1003 proc close-target {} {
1012 .bot.a.set configure -text ""
1016 show-status {Not connected} 0 0
1019 configure-disable-e .top.target.m 1
1020 configure-disable-e .top.target.m 2
1022 .top.rset.m delete 2 last
1024 .top.rset.m delete 1 last
1026 .top.rset.m add separator
1027 configure-enable-e .top.target.m 0
1030 proc load-set-action {} {
1034 ir-set z39.$setNoLast z39
1036 set fname [.load-set.top.filename.entry get]
1039 show-status Loading 1 {}
1041 z39.$setNoLast loadFile $fname
1043 set no [z39.$setNoLast numberOfRecordsReturned]
1044 add-title-lines $setNoLast $no 1
1046 set l [format "%-4d %7d" $setNoLast $no]
1047 .top.rset.m add command -label $l \
1048 -command [list add-title-lines $setNoLast 10000 1]
1049 show-status Ready 0 {}
1055 set oldFocus [focus]
1059 frame $w.top.filename
1060 pack $w.top.filename -side top -anchor e -pady 2
1062 entry-fields $w.top {filename} \
1064 {load-set-action} {destroy .load-set}
1066 top-down-ok-cancel $w {load-set-action} 1
1070 proc init-request {} {
1077 z39 callback {init-response}
1078 show-status Initializing 1 {}
1079 set err [catch {z39 init} errorMessage]
1081 tkerror $errorMessage
1082 show-status Ready 0 {}
1086 proc init-response {} {
1090 dputs {init-reponse}
1095 if {![z39 initResult]} {
1096 show-status Ready 0 1
1097 set u [z39 userInformationField]
1099 tkerror "Connection rejected by target: $u"
1101 if {[lsearch [z39 options] scan] >= 0} {
1106 show-status Ready 0 1
1110 proc search-request {bflag} {
1119 global elementSetNames
1123 if {[z39 connect] == ""} {
1126 dputs "search-request"
1128 if {!$bflag && $busy} {
1129 dputs "busy: search-request ignored"
1134 show-status Searching 1 0
1135 set delayRequest {search-request 1}
1140 set query [index-query]
1145 set setNo $setNoLast
1146 ir-set z39.$setNo z39
1148 if {[lindex $profile($target) 10] == 1} {
1149 z39.$setNo setName $setNo
1150 dputs "setName=${setNo}"
1152 z39.$setNo setName Default
1153 dputs "setName=Default"
1155 if {[lindex $profile($target) 8] == 1} {
1156 z39.$setNo queryType rpn
1158 if {[lindex $profile($target) 9] == 1} {
1159 z39.$setNo queryType ccl
1163 if {$recordSyntax == "None" } {
1164 z39.$setNo preferredRecordSyntax {}
1166 z39.$setNo preferredRecordSyntax $recordSyntax
1168 if {$elementSetNames == "None" } {
1169 z39.$setNo elementSetNames {}
1170 z39.$setNo smallSetElementSetNames {}
1171 z39.$setNo mediumSetElementSetNames {}
1173 z39.$setNo elementSetNames $elementSetNames
1174 z39.$setNo smallSetElementSetNames $elementSetNames
1175 z39.$setNo mediumSetElementSetNames $elementSetNames
1177 z39 callback {search-response}
1178 z39.$setNo search $query
1179 show-status Searching 1 0
1182 proc scan-copy {y entry} {
1184 set no [$w.top.list nearest $y]
1186 .lines.$entry.e delete 0 end
1187 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
1190 proc scan-request {} {
1197 global curIndexEntry
1198 global queryButtonsFind
1199 global queryInfoFind
1203 dputs "scan-request"
1206 show-status Scanning 1 0
1207 set delayRequest scan-request
1216 set b [lindex $queryButtonsFind $curIndexEntry]
1218 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
1219 set attr "@attr $a $attr"
1221 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
1222 ir-scan z39.scan z39
1224 if {![winfo exists $w]} {
1231 entry $w.top.entry -relief sunken
1232 pack $w.top.entry -fill x -padx 4 -pady 2
1233 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
1234 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
1236 scrollbar $w.top.scroll -orient vertical -border 1
1237 pack $w.top.list -side left -fill both -expand yes
1238 pack $w.top.scroll -side right -fill y
1239 $w.top.scroll config -command [list $w.top.list yview]
1241 bottom-buttons $w [list {Close} [list destroy $w] \
1242 {Up} [list scan-up $attr] \
1243 {Down} [list scan-down $attr]] 0
1244 bind $w.top.list <Up> [list scan-up $attr]
1245 bind $w.top.list <Down> [list scan-down $attr]
1248 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
1249 wm title $w "Scan $title"
1251 z39 callback [list scan-response $attr 0 35]
1252 z39.scan numberOfTermsRequested 5
1253 z39.scan preferredPositionInResponse 1
1254 z39.scan scan "${attr} 0"
1256 show-status Scanning 1 0
1259 proc scan-term-h {attr} {
1267 set nScanTerm [$w.top.entry get]
1268 if {$nScanTerm == $scanTerm} {
1271 set scanTerm $nScanTerm
1272 z39 callback [list scan-response $attr 0 35]
1273 z39.scan numberOfTermsRequested 5
1274 z39.scan preferredPositionInResponse 1
1275 dputs "${attr} \{${scanTerm}\}"
1276 if {$scanTerm == ""} {
1277 z39.scan scan "${attr} 0"
1279 z39.scan scan "${attr} \{${scanTerm}\}"
1281 show-status Scanning 1 0
1284 proc scan-response {attr start toget} {
1291 dputs "In scan-response"
1292 set m [z39.scan numberOfEntriesReturned]
1298 if {![winfo exists .scan-window]} {
1301 dputs "Handling cancel"
1302 if {$delayRequest != ""} {
1307 show-status Ready 0 1
1310 set nScanTerm [$w.top.entry get]
1311 if {$nScanTerm != $scanTerm} {
1312 z39 callback [list scan-response $attr 0 35]
1313 z39.scan numberOfTermsRequested 5
1314 z39.scan preferredPositionInResponse 1
1315 set scanTerm $nScanTerm
1316 dputs "${attr} \{${scanTerm}\}"
1317 if {$scanTerm == ""} {
1318 z39.scan scan "${attr} 0"
1320 z39.scan scan "${attr} \{${scanTerm}\}"
1322 show-status Scanning 1 0
1325 set status [z39.scan scanStatus]
1328 show-status Ready 0 1
1333 for {set i 0} {$i < $m} {incr i} {
1334 set term [lindex [z39.scan scanLine $i] 1]
1335 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1336 $w.top.list insert $i "$nostr $term"
1339 $w.top.list yview $scanView
1341 $w.top.list delete $start end
1342 for {set i 0} {$i < $m} {incr i} {
1343 set term [lindex [z39.scan scanLine $i] 1]
1344 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1345 $w.top.list insert end "$nostr $term"
1349 dputs "Handling cancel"
1351 if {$delayRequest != ""} {
1357 if {$toget > 0 && $m > 1 && $m < $toget} {
1358 set ntoget [expr $toget - $m + 1]
1359 dputs ntoget=$ntoget
1360 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1362 dputs "down continue: $q"
1364 z39.scan numberOfTermsRequested 10
1366 z39.scan numberOfTermsRequested $ntoget
1368 z39.scan preferredPositionInResponse 1
1369 dputs "${attr} \{$q\}"
1370 z39.scan scan "${attr} \{$q\}"
1373 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1374 set ntoget [expr - $toget - $m]
1375 dputs ntoget=$ntoget
1376 z39 callback [list scan-response $attr 0 -$ntoget]
1377 set q [string range [$w.top.list get 0] 8 end]
1378 dputs "up continue: $q"
1380 z39.scan numberOfTermsRequested 10
1381 z39.scan preferredPositionInResponse 11
1383 z39.scan numberOfTermsRequested $ntoget
1384 z39.scan preferredPositionInResponse [incr ntoget]
1386 dputs "${attr} \{$q\}"
1387 z39.scan scan "${attr} \{$q\}"
1390 show-status Ready 0 1
1393 proc scan-down {attr} {
1401 show-status {Scanning down} 1 0
1402 set delayRequest [list scan-down $attr]
1408 set scanView [expr $scanView + 5]
1409 set s [$w.top.list size]
1410 if {$scanView > $s} {
1411 z39 callback [list scan-response $attr [expr $s - 1] 25]
1412 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1414 z39.scan numberOfTermsRequested 10
1415 z39.scan preferredPositionInResponse 1
1416 show-status Scanning 1 0
1417 dputs "${attr} \{$q\}"
1418 z39.scan scan "${attr} \{$q\}"
1421 $w.top.list yview $scanView
1424 proc scan-up {attr} {
1432 show-status Scanning 1 0
1433 set delayRequest [list scan-up $attr]
1439 set scanView [expr $scanView - 5]
1440 if {$scanView < 0} {
1441 z39 callback [list scan-response $attr 0 -25]
1442 set q [string range [$w.top.list get 0] 8 end]
1444 z39.scan numberOfTermsRequested 10
1445 z39.scan preferredPositionInResponse 11
1446 show-status Scanning 1 0
1447 z39.scan scan "${attr} \{$q\}"
1450 $w.top.list yview $scanView
1453 proc search-response {} {
1461 dputs "In search-response"
1463 dputs "Handling cancel"
1465 if {$delayRequest != ""} {
1473 set setMax [z39.$setNo resultCount]
1474 show-status Ready 0 1
1475 set status [z39.$setNo responseStatus]
1476 if {[lindex $status 0] == "NSD"} {
1477 z39.$setNo nextResultSetPosition 0
1478 set code [lindex $status 1]
1479 set msg [lindex $status 2]
1480 set addinfo [lindex $status 3]
1481 tkerror "NSD$code: $msg: $addinfo"
1484 show-message "${setMax} hits"
1489 show-status Ready 0 1
1490 set l [format "%-4d %7d" $setNo $setMax]
1491 .top.rset.m add command -label $l \
1492 -command [list add-title-lines $setNo 10000 1]
1496 set no [z39.$setNo numberOfRecordsReturned]
1497 dputs "Returned $no records, setOffset $setOffset"
1498 add-title-lines $setNo $no $setOffset
1499 set setOffset [expr $setOffset + $no]
1500 z39 callback {present-response}
1501 z39.$setNo present $setOffset 1
1502 show-status Retrieving 1 0
1505 proc present-more {number} {
1513 dputs "present-more"
1515 show-status Retrieving 1 0
1516 set delayRequest "present-more $number"
1522 dputs "setNo=$setNo"
1525 set setOffset [z39.$setNo nextResultSetPosition]
1526 dputs "setOffest=${setOffset}"
1527 dputs "setNo=${setNo}"
1528 set max [z39.$setNo resultCount]
1529 if {$max < $setOffset} {
1531 dputs "setOffset=$setOffset"
1532 show-status Ready 0 1
1535 if {$number == ""} {
1539 if {$setMax > $max} {
1543 z39 callback {present-response}
1545 set toGet [expr $setMax - $setOffset + 1]
1552 z39.$setNo present $setOffset $toGet
1553 show-status Retrieving 1 0
1556 proc init-title-lines {} {
1557 .data.record delete 0.0 end
1560 proc add-title-lines {setno no offset} {
1561 global displayFormats
1562 global displayFormat
1566 dputs "add-title-lines offset=${offset} no=${no}"
1574 .bot.a.set configure -text $setno
1575 .data.record delete 0.0 end
1577 set ffunc [lindex $displayFormats $displayFormat]
1578 dputs "ffunc=$ffunc"
1579 set ffunc "display-$ffunc"
1580 for {set i 0} {$i < $no} {incr i} {
1581 set o [expr $i + $offset]
1582 set type [z39.$setno type $o]
1584 dputs "no more at $o"
1587 .data.record tag bind r$o <Any-Enter> {}
1588 .data.record tag bind r$o <Any-Leave> {}
1589 set insert0 [.data.record index insert]
1590 $ffunc $setno $o .data.record 1
1591 .data.record tag add r$o $insert0 insert
1592 .data.record tag bind r$o <1> \
1593 [list popup-marc $setno $o 0 0]
1597 show-status Ready 0 1
1601 proc present-response {} {
1608 dputs "In present-response"
1609 set no [z39.$setNo numberOfRecordsReturned]
1610 dputs "Returned $no records, setOffset $setOffset"
1611 add-title-lines $setNo $no $setOffset
1612 set setOffset [expr $setOffset + $no]
1614 dputs "Handling cancel"
1616 if {$delayRequest != ""} {
1621 set status [z39.$setNo responseStatus]
1622 if {[lindex $status 0] == "NSD"} {
1623 show-status Ready 0 1
1624 set code [lindex $status 1]
1625 set msg [lindex $status 2]
1626 set addinfo [lindex $status 3]
1627 tkerror "NSD$code: $msg: $addinfo"
1630 if {$no > 0 && $setOffset <= $setMax} {
1631 dputs "present-request from ${setOffset}"
1632 set toGet [expr $setMax - $setOffset + 1]
1636 z39.$setNo present $setOffset $toGet
1638 show-status Ready 0 1
1642 proc left-cursor {w} {
1643 set i [$w index insert]
1651 proc right-cursor {w} {
1652 set i [$w index insert]
1658 proc bind-fields {list returnAction escapeAction} {
1659 set max [expr [llength $list]-1]
1660 for {set i 0} {$i < $max} {incr i} {
1661 bind [lindex $list $i] <Return> $returnAction
1662 bind [lindex $list $i] <Escape> $escapeAction
1664 bind [lindex $list $i] <Tab> \
1665 [list focus [lindex $list [expr $i+1]]]
1666 bind [lindex $list $i] <Left> \
1667 [list left-cursor [lindex $list $i]]
1668 bind [lindex $list $i] <Right> \
1669 [list right-cursor [lindex $list $i]]
1672 bind [lindex $list $i] <Return> $returnAction
1673 bind [lindex $list $i] <Escape> $escapeAction
1675 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1676 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1677 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1679 focus [lindex $list 0]
1682 proc entry-fields {parent list tlist returnAction escapeAction} {
1685 foreach field $list {
1686 set label ${parent}.${field}.label
1687 set entry ${parent}.${field}.entry
1688 label $label -text [lindex $tlist $i] -anchor e
1689 entry $entry -width 32 -relief sunken
1690 pack $label -side left
1691 pack $entry -side right
1692 lappend alist $entry
1695 bind-fields $alist $returnAction $escapeAction
1698 proc define-target-dialog {} {
1699 set w .target-define
1705 pack $w.top.target \
1706 -side top -anchor e -pady 2
1707 entry-fields $w.top {target} \
1709 {define-target-action} {destroy .target-define}
1710 top-down-ok-cancel $w {define-target-action} 1
1713 proc protocol-setup-delete {target w} {
1715 global settingsChanged
1717 set a [alert "Are you sure you want to delete the target \
1718 definition $target ?"]
1721 unset profile($target)
1722 set settingsChanged 1
1724 delete-target-hotlist $target
1728 proc protocol-setup-action {target w} {
1731 global protocolRadioType
1732 global settingsChanged
1735 global ResultSetCheck
1738 set settingsChanged 1
1739 set len [$w.top.databases.list size]
1740 for {set i 0} {$i < $len} {incr i} {
1741 lappend b [$w.top.databases.list get $i]
1743 set wno [lindex $profile($target) 12]
1745 set profile($target) [list [$w.top.description.entry get] \
1746 [$w.top.host.entry get] \
1747 [$w.top.port.entry get] \
1748 [$w.top.idAuthentication.entry get] \
1749 [$w.top.maximumRecordSize.entry get] \
1750 [$w.top.preferredMessageSize.entry get] \
1756 $protocolRadioType \
1760 delete-target-hotlist $target
1761 dputs $profile($target)
1765 proc place-force {window parent} {
1766 set g [wm geometry $parent]
1768 set p1 [string first + $g]
1769 set p2 [string last + $g]
1771 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1772 set y [expr 60+[string range $g [expr $p2 +1] end]]
1773 wm geometry $window +${x}+${y}
1776 proc add-database-action {target w} {
1779 $w.top.databases.list insert end \
1780 [.database-select.top.database.entry get]
1781 destroy .database-select
1784 proc add-database {target wp} {
1787 set w .database-select
1789 set oldFocus [focus]
1795 frame $w.top.database
1797 pack $w.top.database -side top -anchor e -pady 2
1799 entry-fields $w.top {database} \
1800 {{Database to add:}} \
1801 [list add-database-action $target $wp] {destroy .database-select}
1803 top-down-ok-cancel $w [list add-database-action $target $wp] 1
1807 proc delete-database {target w} {
1811 foreach i [$w.top.databases.list curselection] {
1812 set b [$w.top.databases.list get $i]
1815 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1817 foreach i [lsort -decreasing \
1818 [$w.top.databases.list curselection]] {
1819 $w.top.databases.list delete $i
1824 proc protocol-setup {target} {
1827 global protocolRadioType
1830 global ResultSetCheck
1833 while {[winfo exists .setup-$b]} {
1840 wm title $w "Setup $target"
1844 if {$target == ""} {
1848 dputs $profile($target)
1850 frame $w.top.description
1853 frame $w.top.idAuthentication
1854 frame $w.top.maximumRecordSize
1855 frame $w.top.preferredMessageSize
1856 frame $w.top.cs-type -relief ridge -border 2
1857 frame $w.top.protocol -relief ridge -border 2
1858 frame $w.top.query -relief ridge -border 2
1859 frame $w.top.databases -relief ridge -border 2
1861 # Maximum/preferred/idAuth ...
1862 pack $w.top.description $w.top.host $w.top.port \
1863 $w.top.idAuthentication $w.top.maximumRecordSize \
1864 $w.top.preferredMessageSize -side top -anchor e -pady 2
1866 entry-fields $w.top {description host port idAuthentication \
1867 maximumRecordSize preferredMessageSize} \
1868 {{Description:} {Host:} {Port:} {Id Authentication:} \
1869 {Maximum Record Size:} {Preferred Message Size:}} \
1870 [list protocol-setup-action $target $w] [list destroy $w]
1872 foreach sub {description host port idAuthentication \
1873 maximumRecordSize preferredMessageSize} {
1875 bind $w.top.$sub.entry <Control-a> [list add-database $target $w]
1876 bind $w.top.$sub.entry <Control-d> [list delete-database $target $w]
1878 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1879 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1880 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1881 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1882 $w.top.maximumRecordSize.entry insert 0 [lindex $profile($target) 4]
1883 $w.top.preferredMessageSize.entry insert 0 [lindex $profile($target) 5]
1884 set csRadioType [lindex $profile($target) 6]
1885 set RPNCheck [lindex $profile($target) 8]
1886 set CCLCheck [lindex $profile($target) 9]
1887 set ResultSetCheck [lindex $profile($target) 10]
1888 set protocolRadioType [lindex $profile($target) 11]
1889 if {$protocolRadioType == ""} {
1890 set protocolRadioType Z39
1894 pack $w.top.databases -side left -pady 2 -padx 2 -expand yes -fill both
1896 label $w.top.databases.label -text "Databases"
1897 button $w.top.databases.add -text Add \
1898 -command [list add-database $target $w]
1899 button $w.top.databases.delete -text Delete \
1900 -command [list delete-database $target $w]
1902 listbox $w.top.databases.list -geometry 14x6 \
1903 -yscrollcommand "$w.top.databases.scroll set"
1905 listbox $w.top.databases.list -width 14 -height 5\
1906 -yscrollcommand "$w.top.databases.scroll set"
1908 scrollbar $w.top.databases.scroll -orient vertical -border 1
1909 pack $w.top.databases.label -side top -fill x \
1911 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1913 pack $w.top.databases.list -side left -fill both -expand yes \
1915 pack $w.top.databases.scroll -side right -fill y \
1917 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1919 foreach b [lindex $profile($target) 7] {
1920 $w.top.databases.list insert end $b
1924 pack $w.top.cs-type -pady 2 -padx 2 -side top -fill x
1926 label $w.top.cs-type.label -text "Transport"
1927 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1928 -variable csRadioType -value tcpip
1929 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1930 -variable csRadioType -value mosi
1932 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1933 -padx 2 -side top -fill x
1936 pack $w.top.protocol -pady 2 -padx 2 -side top -fill x
1938 label $w.top.protocol.label -text "Protocol"
1939 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1940 -variable protocolRadioType -value Z39
1941 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1942 -variable protocolRadioType -value SR
1944 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1945 -padx 2 -side top -fill x
1948 pack $w.top.query -pady 2 -padx 2 -side top -fill x
1950 label $w.top.query.label -text "Query support"
1951 checkbutton $w.top.query.c1 -text "RPN query" -anchor w -variable RPNCheck
1952 checkbutton $w.top.query.c2 -text "CCL query" -anchor w -variable CCLCheck
1953 checkbutton $w.top.query.c3 -text "Result sets" -anchor w -variable ResultSetCheck
1955 pack $w.top.query.label -side top
1956 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
1957 -padx 2 -side top -fill x
1960 bottom-buttons $w [list {Ok} [list protocol-setup-action $target $w] \
1961 {Delete} [list protocol-setup-delete $target $w] \
1962 {Cancel} [list destroy $w]] 0
1965 proc database-select-action {} {
1966 set w .database-select.top
1968 foreach indx [$w.databases.list curselection] {
1969 lappend b [$w.databases.list get $indx]
1972 z39 databaseNames $b
1974 destroy .database-select
1977 proc database-select {} {
1978 set w .database-select
1983 set oldFocus [focus]
1988 frame $w.top.databases -relief ridge -border 2
1990 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
1992 label $w.top.databases.label -text "List"
1993 listbox $w.top.databases.list -width 20 -height 6 \
1994 -yscrollcommand "$w.top.databases.scroll set"
1995 scrollbar $w.top.databases.scroll -orient vertical -border 1
1996 pack $w.top.databases.label -side top -fill x \
1998 pack $w.top.databases.list -side left -fill both -expand yes \
2000 pack $w.top.databases.scroll -side right -fill y \
2002 $w.top.databases.scroll config -command "$w.top.databases.list yview"
2004 foreach b [lindex $profile($hostid) 7] {
2005 $w.top.databases.list insert end $b
2007 top-down-ok-cancel $w {database-select-action} 1
2011 proc cascade-target-list {} {
2014 foreach sub [winfo children .top.target.m.clist] {
2017 .top.target.m.clist delete 0 last
2018 foreach n [lsort [array names profile]] {
2019 if {$n != "Default"} {
2020 set nl [lindex $profile($n) 12]
2021 if {[llength [lindex $profile($n) 7]] > 1} {
2022 .top.target.m.clist add cascade -label $n \
2023 -menu .top.target.m.clist.$nl
2024 menu .top.target.m.clist.$nl
2025 foreach b [lindex $profile($n) 7] {
2026 .top.target.m.clist.$nl add command -label $b \
2027 -command [list reopen-target $n $b]
2030 .top.target.m.clist add command -label $n \
2031 -command [list reopen-target $n {}]
2035 .top.target.m.slist delete 0 last
2036 foreach n [lsort [array names profile]] {
2037 if {$n != "Default"} {
2038 .top.target.m.slist add command -label $n \
2039 -command [list protocol-setup $n]
2044 proc query-select {i} {
2045 global queryButtonsFind
2046 global queryInfoFind
2050 set queryInfoFind [lindex $queryInfo $i]
2051 set queryButtonsFind [lindex $queryButtons $i]
2053 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2056 proc query-new-action {} {
2060 global settingsChanged
2062 set settingsChanged 1
2063 lappend queryTypes [.query-new.top.index.entry get]
2064 lappend queryButtons {}
2065 lappend queryInfo {}
2075 set oldFocus [focus]
2080 -side top -anchor e -pady 2
2081 entry-fields $w.top index \
2083 query-new-action {destroy .query-new}
2084 top-down-ok-cancel $w query-new-action 1
2088 proc query-delete-action {queryNo} {
2092 global settingsChanged
2094 set settingsChanged 1
2096 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
2097 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
2098 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
2099 destroy .query-delete
2103 proc query-delete {queryNo} {
2111 set n [lindex $queryTypes $queryNo]
2113 label $w.top.warning -bitmap warning
2114 message $w.top.quest -text "Are you sure you want to delete the \
2115 query type $n ?" -aspect 300
2116 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
2117 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
2118 {Cancel} [list destroy $w]] 1
2121 proc cascade-query-list {} {
2123 set w .top.options.m.query
2126 $w.slist delete 0 last
2127 foreach n $queryTypes {
2128 $w.slist add command -label $n -command [list query-setup $i]
2133 $w.clist delete 0 last
2134 foreach n $queryTypes {
2135 $w.clist add command -label $n -command [list query-select $i]
2139 $w.dlist delete 0 last
2140 foreach n $queryTypes {
2141 $w.dlist add command -label $n -command [list query-delete $i]
2146 proc save-geometry {} {
2147 global windowGeometry
2150 global displayFormat
2153 global elementSetNames
2155 set windowGeometry(.) [wm geometry .]
2157 if {[catch {set f [open ~/.clientrc.tcl w]}]} {
2160 puts $f "set hotTargets \{ $hotTargets \}"
2161 puts $f "set textWrap $textWrap"
2162 puts $f "set displayFormat $displayFormat"
2163 puts $f "set popupMarcdf $popupMarcdf"
2164 puts $f "set recordSyntax $recordSyntax"
2165 puts $f "set elementSetNames $elementSetNames"
2166 foreach n [array names windowGeometry] {
2167 puts -nonewline $f "set \{windowGeometry($n)\} \{"
2168 puts -nonewline $f $windowGeometry($n)
2174 proc save-settings {} {
2177 global settingsChanged
2182 if {![file writable "${libdir}/clientrc.tcl"]} {
2183 set a [alert "Cannot open ${libdir}/clientrc.tcl for writing. Do you \
2184 wish to save clientrc.tcl in the current directory instead?"]
2188 set f [open "clientrc.tcl" w]
2190 set f [open "${libdir}/clientrc.tcl" w]
2192 puts $f "# Setup file"
2194 foreach n [array names profile] {
2195 puts -nonewline $f "set \{profile($n)\} \{"
2196 puts -nonewline $f $profile($n)
2199 puts -nonewline $f "set queryTypes \{"
2200 puts -nonewline $f $queryTypes
2203 puts -nonewline $f "set queryButtons \{"
2204 puts -nonewline $f $queryButtons
2207 puts -nonewline $f "set queryInfo \{"
2208 puts -nonewline $f $queryInfo
2211 set settingsChanged 0
2220 set oldFocus [focus]
2224 label $w.top.warning -bitmap warning
2225 message $w.top.message -text $ask -aspect 300 \
2226 -font -Adobe-Times-Medium-R-Normal-*-180-*
2228 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
2231 top-down-ok-cancel $w {alert-action} 1
2236 proc alert-action {} {
2242 proc exit-action {} {
2243 global settingsChanged
2245 if {$settingsChanged} {
2246 set a [alert "you haven't saved your settings. Do you wish to save?"]
2255 proc listbuttonaction {w name h user i} {
2256 $w configure -text [lindex $name 0]
2257 $h [lindex $name 1] $user $i
2260 proc listbuttonx {button no names handle user} {
2261 if {[winfo exists $button]} {
2262 $button configure -text [lindex [lindex $names $no] 0]
2263 ${button}.m delete 0 last
2265 menubutton $button -text [lindex [lindex $names $no] 0] \
2266 -width 10 -menu ${button}.m -relief raised -border 1
2270 foreach name $names {
2271 ${button}.m add command -label [lindex $name 0] \
2272 -command [list listbuttonaction ${button} $name \
2278 proc listbutton {button no names} {
2279 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
2280 -relief raised -border 1
2282 foreach name $names {
2283 ${button}.m add command -label $name \
2284 -command [list ${button} configure -text $name]
2288 proc listbuttonv-action {button var names i} {
2291 set $var [lindex $names [expr $i+1]]
2292 $button configure -text [lindex $names $i]
2295 proc listbuttonv {button var names} {
2299 eval "set val $$var"
2300 set l [llength $names]
2301 for {set i 1} {$i < $l} {incr i 2} {
2302 if {$val == [lindex $names $i]} {
2304 set n [lindex $names $i]
2308 if {[winfo exists $button]} {
2309 $button configure -text $n
2312 menubutton $button -text $n -menu ${button}.m \
2313 -relief raised -border 1
2315 for {set i 0} {$i < $l} {incr i 2} {
2316 ${button}.m add command -label [lindex $names $i] \
2317 -command [list listbuttonv-action $button $var $names $i]
2321 proc query-add-index-action {queryNo} {
2325 global queryButtonsTmp
2327 set newI [.query-add-index.top.index.entry get]
2328 lappend queryInfoTmp [list $newI {}]
2329 $w.top.index.list insert end $newI
2330 destroy .query-add-index
2331 #destroy $w.top.lines
2332 #frame $w.top.lines -relief ridge -border 2
2333 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2334 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2337 proc query-add-line {queryNo} {
2341 global queryButtonsTmp
2343 lappend queryButtonsTmp {I 0}
2345 #destroy $w.top.lines
2346 #frame $w.top.lines -relief ridge -border 2
2347 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2348 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2351 proc query-del-line {queryNo} {
2355 global queryButtonsTmp
2357 set l [llength $queryButtonsTmp]
2362 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
2363 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2366 proc query-add-index {queryNo} {
2367 set w .query-add-index
2370 set oldFocus [focus]
2371 place-force $w .query-setup
2375 -side top -anchor e -pady 2
2376 entry-fields $w.top {index} \
2378 [list query-add-index-action $queryNo] [list destroy $w]
2379 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
2383 proc query-setup-action {queryNo} {
2386 global queryButtonsTmp
2388 global queryButtonsFind
2389 global queryInfoFind
2391 global settingsChanged
2393 set settingsChanged 1
2395 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
2397 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
2399 set queryInfoFind $queryInfoTmp
2400 set queryButtonsFind $queryButtonsTmp
2402 destroy .query-setup
2403 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2406 proc activate-e-index {value no i} {
2407 global queryButtonsTmp
2408 global queryIndexTmp
2410 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
2411 dputs $queryButtonsTmp
2412 set queryIndexTmp $i
2415 proc activate-index {value no i} {
2416 global queryButtonsFind
2418 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
2420 dputs "queryButtonsFind $queryButtonsFind"
2423 proc update-attr {} {
2425 listbuttonv $w.top.relation.b relationTmpValue\
2426 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
2427 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
2428 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
2429 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
2430 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
2431 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
2432 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
2433 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
2434 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
2435 {local-number} 107 {string} 108 {numeric string} 109}
2436 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2437 {Left} 2 {Left and right} 3 {No truncation} 100 \
2438 {Process #} 101 {Re-1} 102 {Re-2} 103}
2439 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2440 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2443 proc use-attr {init} {
2455 {BNB card number} 10
2456 {BGF(sic) number} 11
2458 {Dewey classification} 13
2459 {UDC classification} 14
2460 {Bliss classification} 15
2462 {NLM call number} 17
2463 {NAL call number} 18
2464 {MOS call number} 19
2465 {Local classification} 20
2466 {Subject heading} 21
2468 {BDI-index-subject} 23
2472 {LC-subject-heading} 27
2473 {RVM-subject-heading} 28
2474 {Local subject index} 29
2476 {Date of publication} 31
2477 {Date of acquisition} 32
2479 {Title-collective} 34
2482 {Title-added-title-page} 37
2486 {Title-other-variant} 41
2488 {Title-abbreviated} 43
2492 {Subject-subdivision} 47
2493 {Number-natl-bibliography} 48
2494 {Number-legal-deposit} 49
2495 {Number-govt-publication} 50
2496 {Number-publisher-for-music} 51
2498 {Number-local-call} 53
2500 {Code-geographic-area} 55
2501 {Code-institution} 56
2503 {Name-geographic} 58
2504 {Place-publication} 59
2506 {Microform-generation} 61
2513 {Author-name-personal} 1004
2514 {Author-name-corporate} 1005
2515 {Author-name-conference} 1006
2516 {Identifier-standard} 1007
2517 {Subject-LC-children's} 1008
2518 {Subject-name-personal} 1009
2520 {Date/time added to database} 1011
2521 {Date/time last modified} 1012
2522 {Authority/format identifier} 1013
2524 {Concept-reference} 1015
2526 {Server choice} 1017
2528 {Record source} 1019
2531 {Geographic class} 1022
2535 {Related periodical} 1026
2536 {Report number} 1027
2538 {Thematic number} 1030
2539 {Material type} 1031
2547 set l [llength $attr]
2552 for {set i 0} {$i < $l} {incr i} {
2553 $w.top.use.list insert end [lindex $attr $i]
2555 if {$useTmpValue == [lindex $attr $i]} {
2561 $w.top.use.list selection clear 0 end
2562 $w.top.use.list selection set $s $s
2564 $w.top.use.list select from $s
2565 $w.top.use.list select to $s
2571 $w.top.use.list yview $s
2573 set lno [lindex [$w.top.use.list curselection] 0]
2574 set i [expr $lno+$lno+1]
2575 set useTmpValue [lindex $attr $i]
2576 dputs "useTmpValue=$useTmpValue"
2580 proc index-setup-action {oldAttr queryNo indexNo} {
2581 set attr [lindex $oldAttr 0]
2584 global relationTmpValue
2585 global structureTmpValue
2586 global truncationTmpValue
2587 global completenessTmpValue
2588 global positionTmpValue
2593 dputs "index-setup-action"
2594 dputs "queryNo $queryNo"
2595 dputs "indexNo $indexNo"
2596 if {$useTmpValue > 0} {
2597 lappend attr "1=$useTmpValue"
2599 if {$relationTmpValue > 0} {
2600 lappend attr "2=$relationTmpValue"
2602 if {$positionTmpValue > 0} {
2603 lappend attr "3=$positionTmpValue"
2605 if {$structureTmpValue > 0} {
2606 lappend attr "4=$structureTmpValue"
2608 if {$truncationTmpValue > 0} {
2609 lappend attr "5=$truncationTmpValue"
2611 if {$completenessTmpValue > 0} {
2612 lappend attr "6=$completenessTmpValue"
2614 dputs "new attr $attr"
2615 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2616 destroy .index-setup
2619 proc index-setup {attr queryNo indexNo} {
2622 global relationTmpValue
2623 global structureTmpValue
2624 global truncationTmpValue
2625 global completenessTmpValue
2626 global positionTmpValue
2628 set relationTmpValue 0
2629 set truncationTmpValue 0
2630 set structureTmpValue 0
2631 set positionTmpValue 0
2632 set completenessTmpValue 0
2638 set n [lindex $attr 0]
2639 wm title $w "Index setup $n"
2643 set len [llength $attr]
2644 for {set i 1} {$i < $len} {incr i} {
2645 set q [lindex $attr $i]
2646 set l [string first = $q]
2648 set t [string range $q 0 [expr $l - 1]]
2649 set v [string range $q [expr $l + 1] end]
2652 { set useTmpValue $v }
2654 { set relationTmpValue $v }
2656 { set positionTmpValue $v }
2658 { set structureTmpValue $v }
2660 { set truncationTmpValue $v }
2662 { set completenessTmpValue $v }
2667 frame $w.top.use -relief ridge -border 2
2668 frame $w.top.relation -relief ridge -border 2
2669 frame $w.top.position -relief ridge -border 2
2670 frame $w.top.structure -relief ridge -border 2
2671 frame $w.top.truncation -relief ridge -border 2
2672 frame $w.top.completeness -relief ridge -border 2
2678 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2680 label $w.top.use.label -text "Use"
2682 listbox $w.top.use.list -width 26 \
2683 -yscrollcommand "$w.top.use.scroll set"
2685 listbox $w.top.use.list -geometry 26x10 \
2686 -yscrollcommand "$w.top.use.scroll set"
2688 scrollbar $w.top.use.scroll -orient vertical -border 1
2689 pack $w.top.use.label -side top -fill x \
2691 pack $w.top.use.list -side left -fill both -expand yes \
2693 pack $w.top.use.scroll -side right -fill y \
2695 $w.top.use.scroll config -command "$w.top.use.list yview"
2699 # Relation Attributes
2701 pack $w.top.relation -pady 6 -padx 6 -side top
2702 label $w.top.relation.label -text "Relation" -width 18
2704 pack $w.top.relation.label $w.top.relation.b -fill x
2706 # Position Attributes
2708 pack $w.top.position -pady 6 -padx 6 -side top
2709 label $w.top.position.label -text "Position" -width 18
2711 pack $w.top.position.label $w.top.position.b -fill x
2713 # Structure Attributes
2715 pack $w.top.structure -pady 6 -padx 6 -side top
2716 label $w.top.structure.label -text "Structure" -width 18
2718 pack $w.top.structure.label $w.top.structure.b -fill x
2720 # Truncation Attributes
2722 pack $w.top.truncation -pady 6 -padx 6 -side top
2723 label $w.top.truncation.label -text "Truncation" -width 18
2725 pack $w.top.truncation.label $w.top.truncation.b -fill x
2727 # Completeness Attributes
2729 pack $w.top.completeness -pady 6 -padx 6 -side top
2730 label $w.top.completeness.label -text "Completeness" -width 18
2732 pack $w.top.completeness.label $w.top.completeness.b -fill x
2735 bottom-buttons $w [list \
2736 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2737 {Cancel} [list destroy $w]] 0
2741 proc query-edit-index {queryNo} {
2745 set i [lindex [$w.top.index.list curselection] 0]
2749 set attr [lindex $queryInfoTmp $i]
2750 dputs "Editing no $i $attr"
2751 index-setup $attr $queryNo $i
2754 proc query-delete-index {queryNo} {
2756 global queryButtonsTmp
2759 set i [lindex [$w.top.index.list curselection] 0]
2763 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2764 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2765 $w.top.index.list delete $i
2768 proc query-setup {queryNo} {
2774 global queryButtonsTmp
2776 global queryIndexTmp
2779 set queryName [lindex $queryTypes $queryNo]
2780 set queryInfoTmp [lindex $queryInfo $queryNo]
2781 set queryButtonsTmp [lindex $queryButtons $queryNo]
2786 wm title $w "Query setup $queryName"
2790 frame $w.top.lines -relief ridge -border 2
2792 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2796 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2798 button $w.top.lines.add -text "Add" \
2799 -command [list query-add-line $queryNo]
2800 button $w.top.lines.del -text "Remove" \
2801 -command [list query-del-line $queryNo]
2803 pack $w.top.lines.del -fill x -side bottom
2804 pack $w.top.lines.add -fill x -pady 10 -side bottom
2808 frame $w.top.index -relief ridge -border 2
2809 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2811 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2812 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2813 -command [list $w.top.index.list yview]
2814 bind $w.top.index.list <Double-1> [list query-edit-index $queryNo]
2816 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2817 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2820 $w.top.index.list selection clear 0 end
2821 $w.top.index.list selection set 0 0
2823 $w.top.index.list select from 0
2824 $w.top.index.list select to 0
2827 foreach x $queryInfoTmp {
2828 $w.top.index.list insert end [lindex $x 0]
2832 bottom-buttons $w [list \
2833 Ok [list query-setup-action $queryNo] \
2834 Add [list query-add-index $queryNo] \
2835 Edit [list query-edit-index $queryNo] \
2836 Delete [list query-delete-index $queryNo] \
2837 Cancel [list destroy $w]] 0
2840 proc index-clear {} {
2841 global queryButtonsFind
2844 foreach b $queryButtonsFind {
2845 .lines.$i.e delete 0 end
2850 proc index-query {} {
2851 global queryButtonsFind
2852 global queryInfoFind
2857 foreach b $queryButtonsFind {
2858 set term [string trim [.lines.$i.e get]]
2860 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
2863 set len [string length $term]
2867 if {[string index $term 0] == ">"} {
2868 if {[string index $term 1] == "=" } {
2869 set term [string trim [string range $term 2 $len]]
2872 set term [string trim [string range $term 1 $len]]
2875 } elseif {[string index $term 0] == "<"} {
2876 if {[string index $term 1] == "=" } {
2877 set term [string trim [string range $term 2 $len]]
2879 } elseif {[string index $term 1] == ">"} {
2880 set term [string trim [string range $term 2 $len]]
2883 set term [string trim [string range $term 1 $len]]
2888 set len [string length $term]
2892 if {[string index $term $len] == "?"} {
2894 set term [string range $term 0 [expr $len - 1]]
2896 if {[string index $term 0] == "?"} {
2898 set term [string range $term 1 end]
2900 set term "\{${term}\}"
2901 if {$right && $left} {
2902 set term "@attr 5=3 ${term}"
2904 set term "@attr 5=1 ${term}"
2906 set term "@attr 5=2 ${term}"
2908 if {$relation != ""} {
2909 set term "@attr 2=${relation} ${term}"
2912 set term "@attr $a ${term}"
2915 set qs "@and ${qs} ${term}"
2926 proc index-focus-in {w i} {
2927 global curIndexEntry
2930 $w.$i configure -background red
2932 set curIndexEntry $i
2935 proc index-lines {w realOp buttonInfo queryInfo handle} {
2937 foreach b $buttonInfo {
2938 if {! [winfo exists $w.$i]} {
2940 frame $w.$i -border 0
2942 frame $w.$i -background white -border 1
2945 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
2948 if {! [winfo exists $w.$i.e]} {
2949 entry $w.$i.e -width 32 -relief sunken -border 1
2950 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
2951 bind $w.$i.e <FocusOut> [list $w.$i configure \
2953 pack $w.$i.l -side left
2954 pack $w.$i.e -side left -fill x -expand yes
2955 pack $w.$i -side top -fill x -padx 2 -pady 2
2957 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2958 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2960 bind $w.$i.e <Return> {search-request 0}
2963 pack $w.$i.l -side left
2964 pack $w.$i -side top -fill x -padx 2 -pady 2
2969 while {[winfo exists $w.$j]} {
2981 bind $w.$j.e <Tab> "focus $w.$k.e"
2987 bind $w.$i.e <Tab> "focus $w.0.e"
2993 proc search-fields {w buttondefs} {
2995 foreach buttondef $buttondefs {
2996 frame $w.$i -background white
2998 listbutton $w.$i.l 0 $buttondef
2999 entry $w.$i.e -width 32 -relief sunken
3001 pack $w.$i.l -side left
3002 pack $w.$i.e -side left -fill x -expand yes
3004 pack $w.$i -side top -fill x -padx 2 -pady 2
3006 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
3007 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
3015 bind $w.$j.e <Tab> "focus $w.$k.e \n
3016 $w.$k configure -background red \n
3017 $w.$j configure -background white"
3020 bind $w.$i.e <Tab> "focus $w.0.e \n
3021 $w.0 configure -background red \n
3022 $w.$i configure -background white"
3024 $w.0 configure -background red
3027 if {[info exists windowGeometry(.)]} {
3028 set g $windowGeometry(.)
3036 frame .top -border 1 -relief raised
3037 frame .lines -border 1 -relief raised
3038 frame .mid -border 1 -relief raised
3039 frame .data -border 1 -relief raised
3040 frame .bot -border 1 -relief raised
3041 pack .top .lines .mid -side top -fill x
3042 pack .data -side top -fill both -expand yes
3045 menubutton .top.file -text "File" -menu .top.file.m
3047 .top.file.m add command -label "Save settings" -command {save-settings}
3048 .top.file.m add separator
3049 .top.file.m add command -label "Exit" -command {exit-action}
3051 menubutton .top.target -text "Target" -menu .top.target.m
3053 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
3054 .top.target.m add command -label "Disconnect" -command {close-target}
3055 .top.target.m add command -label "About" -command {about-target}
3056 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
3057 .top.target.m add command -label "Setup new" -command {define-target-dialog}
3058 .top.target.m add separator
3059 set-target-hotlist 0
3061 configure-disable-e .top.target.m 1
3062 configure-disable-e .top.target.m 2
3064 menu .top.target.m.clist
3065 menu .top.target.m.slist
3068 menubutton .top.service -text "Service" -menu .top.service.m
3070 .top.service.m add command -label "Database" -command {database-select}
3071 .top.service.m add cascade -label "Present" -menu .top.service.m.present
3072 menu .top.service.m.present
3073 .top.service.m.present add command -label "10 More" \
3074 -command [list present-more 10]
3075 .top.service.m.present add command -label "All" \
3076 -command [list present-more {}]
3077 .top.service.m add command -label "Search" -command {search-request 0}
3078 .top.service.m add command -label "Scan" -command {scan-request}
3080 .top.service configure -state disabled
3082 menubutton .top.rset -text "Set" -menu .top.rset.m
3084 .top.rset.m add command -label "Load" -command {load-set}
3085 .top.rset.m add separator
3087 menubutton .top.options -text "Options" -menu .top.options.m
3089 .top.options.m add cascade -label "Query" -menu .top.options.m.query
3090 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
3091 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
3092 .top.options.m add cascade -label "Syntax" -menu .top.options.m.syntax
3093 .top.options.m add cascade -label "Elements" -menu .top.options.m.elements
3095 menu .top.options.m.query
3096 .top.options.m.query add cascade -label "Select" \
3097 -menu .top.options.m.query.clist
3098 .top.options.m.query add cascade -label "Edit" \
3099 -menu .top.options.m.query.slist
3100 .top.options.m.query add command -label "New" \
3101 -command {query-new}
3102 .top.options.m.query add cascade -label "Delete" \
3103 -menu .top.options.m.query.dlist
3105 menu .top.options.m.query.slist
3106 menu .top.options.m.query.clist
3107 menu .top.options.m.query.dlist
3110 menu .top.options.m.formats
3112 foreach f $displayFormats {
3113 .top.options.m.formats add radiobutton -label $f -value $i \
3114 -command [list set-display-format $i] -variable displayFormat
3118 menu .top.options.m.wrap
3119 .top.options.m.wrap add radiobutton -label "Character" \
3120 -value char -variable textWrap -command {set-wrap char}
3121 .top.options.m.wrap add radiobutton -label "Word" \
3122 -value word -variable textWrap -command {set-wrap word}
3123 .top.options.m.wrap add radiobutton -label "None" \
3124 -value none -variable textWrap -command {set-wrap none}
3126 menu .top.options.m.syntax
3127 .top.options.m.syntax add radiobutton -label "None" \
3128 -value None -variable recordSyntax
3129 .top.options.m.syntax add separator
3130 .top.options.m.syntax add radiobutton -label "USMARC" \
3131 -value USMARC -variable recordSyntax
3132 .top.options.m.syntax add radiobutton -label "UNIMARC" \
3133 -value UNIMARC -variable recordSyntax
3134 .top.options.m.syntax add radiobutton -label "UKMARC" \
3135 -value UKMARC -variable recordSyntax
3136 .top.options.m.syntax add radiobutton -label "DANMARC" \
3137 -value DANMARC -variable recordSyntax
3138 .top.options.m.syntax add radiobutton -label "FINMARC" \
3139 -value FINMARC -variable recordSyntax
3140 .top.options.m.syntax add radiobutton -label "NORMARC" \
3141 -value NORMARC -variable recordSyntax
3142 .top.options.m.syntax add radiobutton -label "PICAMARC" \
3143 -value PICAMARC -variable recordSyntax
3144 .top.options.m.syntax add separator
3145 .top.options.m.syntax add radiobutton -label "SUTRS" \
3146 -value SUTRS -variable recordSyntax
3147 .top.options.m.syntax add separator
3148 .top.options.m.syntax add radiobutton -label "GRS1" \
3149 -value GRS1 -variable recordSyntax
3151 menu .top.options.m.elements
3152 .top.options.m.elements add radiobutton -label "Unspecified" \
3153 -value None -variable elementSetNames
3154 .top.options.m.elements add radiobutton -label "Full" \
3155 -value F -variable elementSetNames
3156 .top.options.m.elements add radiobutton -label "Brief" \
3157 -value B -variable elementSetNames
3159 menubutton .top.help -text "Help" -menu .top.help.m
3162 .top.help.m add command -label "Help on help" \
3163 -command {tkerror "Help on help not available. Sorry"}
3164 .top.help.m add command -label "About" -command {about-origin}
3166 pack .top.file .top.target .top.service .top.rset .top.options -side left
3167 pack .top.help -side right
3169 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
3171 button .mid.search -text Search -command {search-request 0} \
3173 button .mid.scan -text Scan \
3174 -command scan-request -state disabled
3175 button .mid.present -text {Present} -command [list present-more 10] \
3178 button .mid.clear -text Clear -command index-clear
3179 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
3182 text .data.record -height 2 -width 20 -wrap none \
3183 -yscrollcommand [list .data.scroll set] -wrap $textWrap
3184 scrollbar .data.scroll -command [list .data.record yview]
3186 .data.record configure -takefocus 0
3187 .data.scroll configure -takefocus 0
3189 pack .data.scroll -side right -fill y
3190 pack .data.record -expand yes -fill both
3194 .data.record tag configure marc-tag -foreground blue
3195 .data.record tag configure marc-id -foreground red
3197 .data.record tag configure marc-tag -foreground black
3198 .data.record tag configure marc-id -foreground black
3200 .data.record tag configure marc-data -foreground black
3201 .data.record tag configure marc-head \
3202 -font -Adobe-Times-Bold-R-Normal-*-140-* \
3203 -foreground brown -relief raised -borderwidth 1
3204 .data.record tag configure marc-small-head -foreground brown
3205 .data.record tag configure marc-pref \
3206 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3208 .data.record tag configure marc-text \
3209 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3211 .data.record tag configure marc-it \
3212 -font -Adobe-Times-Medium-I-Normal-*-140-* \
3215 button .bot.logo -bitmap @${libdir}/bitmaps/book1 -command cancel-operation
3217 .bot.logo configure -takefocus 0
3220 pack .bot.a -side left -fill x
3221 pack .bot.logo -side right -padx 2 -pady 2 -ipadx 1
3223 message .bot.a.target -text "" -aspect 1000 -border 1
3225 label .bot.a.status -text "Not connected" -width 15 -relief \
3226 sunken -anchor w -border 1
3227 label .bot.a.set -text "" -width 5 -relief \
3228 sunken -anchor w -border 1
3229 label .bot.a.message -text "" -width 15 -relief \
3230 sunken -anchor w -border 1
3232 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
3233 pack .bot.a.status .bot.a.set .bot.a.message \
3234 -side left -padx 2 -pady 2 -ipadx 1 -ipady 1
3236 if {[catch {ir z39}]} {
3237 set e [info sharedlibextension]
3238 puts -nonewline "Loading irtcl$e ..."
3243 z39 largeSetLowerBound 20
3244 z39 smallSetUpperBound 2
3245 z39 mediumSetPresentNumber 2