1 # IR toolkit for tcl/tk
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
7 # Revision 1.82 1995-11-02 08:47:56 adam
8 # Text widgets are flat now.
10 # Revision 1.81 1995/10/19 10:34:43 adam
11 # More configurable client.
13 # Revision 1.80 1995/10/18 17:20:32 adam
14 # Work on target setup in client.tcl.
16 # Revision 1.79 1995/10/18 16:42:37 adam
17 # New settings: smallSetElementSetNames and mediumSetElementSetNames.
19 # Revision 1.78 1995/10/18 15:45:36 quinn
20 # *** empty log message ***
22 # Revision 1.77 1995/10/18 15:37:46 adam
25 # Revision 1.76 1995/10/18 15:15:20 adam
28 # Revision 1.75 1995/10/17 14:18:05 adam
29 # Minor changes in presentation formats.
31 # Revision 1.74 1995/10/17 12:18:57 adam
32 # Bug fix: when target connection closed, the connection was not
33 # properly reestablished.
35 # Revision 1.73 1995/10/17 10:58:06 adam
36 # More work on presentation formats.
38 # Revision 1.72 1995/10/16 17:00:52 adam
39 # New setting: elementSetNames.
40 # Various client improvements. Medium presentation format looks better.
42 # Revision 1.71 1995/10/13 15:35:27 adam
43 # Relational operators may be used in search entries - changes
44 # in proc index-query.
46 # Revision 1.70 1995/10/12 14:46:52 adam
47 # Better record popup windows. Next/prev buttons in popup record windows.
48 # The record position in the raw format is much more visible.
50 # Revision 1.69 1995/09/21 13:42:54 adam
53 # Revision 1.68 1995/09/21 13:11:49 adam
54 # Support of dynamic loading.
55 # Test script uses load command if necessary.
57 # Revision 1.67 1995/09/20 14:35:19 adam
60 # Revision 1.66 1995/08/29 15:30:13 adam
61 # Work on GRS records.
63 # Revision 1.65 1995/08/24 15:39:09 adam
66 # Revision 1.64 1995/08/24 15:33:02 adam
69 # Revision 1.63 1995/08/04 13:20:48 adam
70 # Buttons at the bottom are slightly smaller.
72 # Revision 1.62 1995/08/04 11:32:37 adam
73 # More work on output queue. Memory related routines moved
76 # Revision 1.61 1995/07/20 08:09:39 adam
77 # client.tcl: Targets removed from hotTargets list when targets
78 # are removed/modified.
79 # ir-tcl.c: More work on triggerResourceControl.
81 # Revision 1.60 1995/06/30 16:30:19 adam
84 # Revision 1.59 1995/06/29 14:06:25 adam
85 # Another bug in install fixed. Configure searches for more versions of yaz.
87 # Revision 1.58 1995/06/29 12:34:06 adam
88 # IrTcl now works with both tk4.0b4/tcl7.4b4 and tk3.6/tcl7.3
90 # Revision 1.57 1995/06/29 09:20:30 adam
91 # Target entries in cascade menus are sorted.
93 # Revision 1.56 1995/06/27 19:03:48 adam
94 # Bug fix in do_present in ir-tcl.c: p->set_child member weren't set.
95 # nextResultSetPosition used instead of setOffset.
97 # Revision 1.55 1995/06/27 17:10:37 adam
98 # Bug fix: install procedure didn't work on some systems.
99 # Error turned up when clientrc.tcl was't present.
101 # Revision 1.54 1995/06/27 14:41:03 adam
102 # Bug fix in search-response. Didn't always observe non-surrogate diagnostics.
104 # Revision 1.53 1995/06/26 12:40:09 adam
105 # Client defines its own tkerror.
106 # User may specify 'no preferredRecordSyntax'.
108 # Revision 1.52 1995/06/22 13:14:59 adam
109 # Feature: SUTRS. Setting getSutrs implemented.
110 # Work on display formats.
111 # Preferred record syntax can be set by the user.
113 # Revision 1.51 1995/06/21 11:11:00 adam
114 # Bug fix: libdir undefined in about-origin.
116 # Revision 1.50 1995/06/21 11:04:48 adam
117 # Uses GNU autoconf 2.3.
118 # Install procedure implemented.
119 # boook bitmaps moved to sub directory bitmaps.
121 # Revision 1.49 1995/06/20 14:16:42 adam
122 # More work on cancel mechanism.
124 # Revision 1.48 1995/06/20 08:07:23 adam
125 # New setting: failInfo.
126 # Working on better cancel mechanism.
128 # Revision 1.47 1995/06/19 14:05:29 adam
129 # Bug fix: asked for SUTRS.
131 # Revision 1.46 1995/06/19 13:06:06 adam
132 # New define: IR_TCL_VERSION.
134 # Revision 1.45 1995/06/19 08:08:44 adam
135 # client.tcl: hotTargets now contain both database and target name.
136 # ir-tcl.c: setting protocol edited. Errors in callbacks are logged
137 # by logf(LOG_WARN, ...) calls.
139 # Revision 1.44 1995/06/16 14:55:18 adam
140 # Book logo mirrored.
142 # Revision 1.43 1995/06/16 14:41:05 adam
143 # Scan line entries can be copied to a search entry.
145 # Revision 1.42 1995/06/16 12:28:13 adam
146 # Implemented preferredRecordSyntax.
147 # Minor changes in diagnostic handling.
148 # Record list deleted when connection closes.
150 # Revision 1.41 1995/06/14 15:07:59 adam
151 # Bug fix in cascade-target-list. Uses yaz-version.h.
153 # Revision 1.40 1995/06/14 13:37:17 adam
154 # Setting recordType implemented.
155 # Setting implementationVersion implemented.
156 # Settings implementationId / implementationName edited.
158 # Revision 1.39 1995/06/14 12:16:22 adam
159 # hotTargets, textWrap and displayFormat saved in clientg.tcl.
161 # Revision 1.38 1995/06/14 07:22:45 adam
162 # Target definitions can be deleted.
163 # Listbox used in the query definition dialog.
165 # Revision 1.37 1995/06/13 14:37:59 adam
166 # Work on query setup.
167 # Better about origin/target.
168 # Better presentation formats.
170 # Revision 1.36 1995/06/13 07:42:14 adam
171 # Bindings removed from text widgets.
173 # Revision 1.35 1995/06/12 15:17:31 adam
174 # Text widget used in main window (instead of listbox) to support
175 # better presentation formats.
177 # Revision 1.34 1995/06/12 07:59:07 adam
178 # More work on geometry handling.
180 # Revision 1.33 1995/06/09 11:17:35 adam
181 # Start work on geometry management.
183 # Revision 1.32 1995/06/07 09:16:37 adam
184 # New presentation format.
186 # Revision 1.31 1995/06/06 16:31:09 adam
187 # Bug fix: target names couldn't contain blanks.
190 # Revision 1.30 1995/06/06 11:35:41 adam
191 # Work on scan. Display of old sets.
193 # Revision 1.29 1995/06/05 14:11:18 adam
194 # Bug fix in present-more.
196 # Revision 1.28 1995/06/02 14:52:13 adam
197 # Minor changes really.
199 # Revision 1.27 1995/06/02 14:29:42 adam
200 # Work on scan interface - up/down buttons.
202 # Revision 1.26 1995/06/01 16:36:46 adam
203 # About buttons. Minor bug fixes.
205 # Revision 1.25 1995/05/31 13:09:57 adam
206 # Client searches/presents may be interrupted.
207 # New moving book-logo.
209 # Revision 1.24 1995/05/31 08:36:24 adam
210 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
211 # New method: referenceId. More work on scan.
213 # Revision 1.23 1995/05/29 10:33:41 adam
214 # README and rename of startup script.
216 # Revision 1.22 1995/05/26 11:44:09 adam
217 # Bugs fixed. More work on MARC utilities and queries. Test
218 # client is up-to-date again.
220 # Revision 1.21 1995/05/11 15:34:46 adam
221 # Scan request changed a bit. This version works with RLG.
223 # Revision 1.20 1995/04/21 16:31:57 adam
224 # New radiobutton: protocol (z39v2/SR).
226 # Revision 1.19 1995/04/18 16:11:50 adam
227 # First version of graphical Scan. Some work on query-by-form.
229 # Revision 1.18 1995/04/10 10:50:22 adam
230 # Result-set name defaults to suffix of ir-set name.
231 # Started working on scan. Not finished at this point.
233 # Revision 1.17 1995/03/31 09:34:57 adam
234 # Search-button disabled when there is no connection.
236 # Revision 1.16 1995/03/31 08:56:36 adam
237 # New button "Search".
239 # Revision 1.15 1995/03/28 12:45:22 adam
240 # New ir method failback: called on disconnect/protocol error.
241 # New ir set/get method: protocol: SR / Z3950.
242 # Simple popup and disconnect when failback is invoked.
244 # Revision 1.14 1995/03/22 16:07:55 adam
247 # Revision 1.13 1995/03/21 17:27:26 adam
248 # Short-hand keys in setup.
250 # Revision 1.12 1995/03/21 13:41:03 adam
251 # Comstack cs_create not used too often. Non-blocking connect.
253 # Revision 1.11 1995/03/21 10:39:06 adam
254 # Diagnostic error message displayed with tkerror.
256 # Revision 1.10 1995/03/20 15:24:06 adam
257 # Diagnostic records saved on searchResponse.
259 # Revision 1.9 1995/03/17 18:26:16 adam
260 # Non-blocking i/o used now. Database names popup as cascade items.
262 # Revision 1.8 1995/03/17 15:45:00 adam
263 # Improved target/database setup.
265 # Revision 1.7 1995/03/16 17:54:03 adam
266 # Minor changes really.
268 # Revision 1.6 1995/03/15 19:10:20 adam
269 # Database setup in protocol-setup (rather target setup).
271 # Revision 1.5 1995/03/15 13:59:23 adam
274 # Revision 1.4 1995/03/14 17:32:29 adam
275 # Presentation of full Marc record in popup window.
277 # Revision 1.3 1995/03/12 19:31:52 adam
278 # Pattern matching implemented when retrieving MARC records. More
279 # diagnostic functions.
281 # Revision 1.2 1995/03/10 18:00:15 adam
282 # Actual presentation in line-by-line format. RPN query support.
284 # Revision 1.1 1995/03/09 16:15:07 adam
285 # First presentRequest attempts. Hot-target list.
289 if {$tk_version == "3.6"} {
300 proc configure-enable-e {w n} {
302 $w entryconfigure $n -state normal
304 proc configure-disable-e {w n} {
306 $w entryconfigure $n -state disabled
308 set noFocus [list -takefocus 0]
310 proc configure-enable-e {w n} {
313 proc configure-disable-e {w n} {
320 if {[tk colormodel .] == "color"} {
330 if {[file readable bitmaps/book2]} {
333 if {! [file readable ${libdir}/bitmaps/book2]} {
334 puts "Cannot locate system files in ${libdir}. You must either run this"
335 puts "program from the source directory root of ir-tcl or you must assure"
336 puts "that it is installed - normally in /usr/local/lib/irtcl"
344 set profile(Default) {{} {} {210} {} 50000 30000 tcpip {} 1 {} {} Z39 1 2 0 0 4}
346 set settingsChanged 0
354 set recordSyntax None
355 set elementSetNames None
358 set queryTypes {Simple}
359 set queryButtons { { {I 0} {I 1} {I 2} } }
360 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
361 {Subject {1=21}} {Any {1=1016}} } }
370 if {[winfo exists $w]} {
379 label $w.top.b -bitmap error
380 message $w.top.t -aspect 300 -text "Error: $err" \
381 -font -Adobe-Helvetica-Bold-R-Normal-*-180-*
382 pack $w.top.b $w.top.t -side left -padx 10 -pady 10
384 bottom-buttons $w [list {Close} [list destroy $w]] 1
387 if {[file readable "clientrc.tcl"]} {
388 source "clientrc.tcl"
390 if {[file readable "${libdir}/clientrc.tcl"]} {
391 source "${libdir}/clientrc.tcl"
395 if {[file readable "~/.clientrc.tcl"]} {
396 source "~/.clientrc.tcl"
399 set queryButtonsFind [lindex $queryButtons 0]
400 set queryInfoFind [lindex $queryInfo 0]
402 proc read-formats {} {
403 global displayFormats
405 if {[catch {set formats [glob -nocomplain ${libdir}/formats/*.tcl]}]} {
406 set formats ./formats/raw.tcl
409 if {[file readable $f]} {
411 set l [string length $f]
412 set f [string range $f [string length "${libdir}/formats/"] \
414 lappend displayFormats $f
423 .data.record configure -wrap $m
430 proc set-display-format {f} {
440 .bot.a.status configure -text "Reformatting"
443 add-title-lines -1 10000 1
446 proc initBindings {} {
449 bind $w <Double-1> {}
450 bind $w <Triple-1> {}
451 bind $w <B1-Motion> {}
453 bind $w <Shift-B1-Motion> {}
455 bind $w <B2-Motion> {}
456 bind $w <Any-KeyPress> {}
458 bind $w <BackSpace> {}
460 bind $w <Control-h> {}
461 bind $w <Control-d> {}
462 bind $w <Control-v> {}
465 bind $w <B1-Motion> {}
466 bind $w <Shift-B1-Motion> {}
471 proc post-menu {wbutton wmenu} {
474 $wmenu post [winfo rootx $wbutton] \
475 [expr [winfo rooty $wbutton]+[winfo height $wbutton]]
480 global windowGeometry
481 set windowGeometry($w) [wm geometry $w]
484 global windowGeometry
487 if {[info exists windowGeometry($w)]} {
488 set g $windowGeometry($w)
493 bind $w <Destroy> [list destroyGW $w]
497 proc top-down-window {w} {
498 frame $w.top -relief raised -border 1
499 frame $w.bot -relief raised -border 1
501 pack $w.top -side top -fill both -expand yes
502 pack $w.bot -fill both
505 proc top-down-ok-cancel {w ok-action g} {
506 frame $w.bot.left -relief sunken -border 1
507 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 1 -pady 1
508 button $w.bot.left.ok -width 4 -text {Ok} \
509 -command ${ok-action}
510 pack $w.bot.left.ok -expand yes -ipadx 1 -ipady 1 -padx 2 -pady 2
511 button $w.bot.cancel -width 5 -text {Cancel} \
512 -command [list destroy $w]
513 pack $w.bot.cancel -side left -expand yes
521 proc bottom-buttons {w buttonList g} {
523 set l [llength $buttonList]
525 frame $w.bot.$i -relief sunken -border 1
526 pack $w.bot.$i -side left -expand yes -padx 2 -pady 2
527 button $w.bot.$i.ok -text [lindex $buttonList $i] \
528 -command [lindex $buttonList [expr $i+1]]
529 pack $w.bot.$i.ok -expand yes -padx 2 -pady 2 -side left
533 button $w.bot.$i -text [lindex $buttonList $i] \
534 -command [lindex $buttonList [expr $i+1]]
535 pack $w.bot.$i -expand yes -padx 2 -pady 2 -side left
545 proc cancel-operation {} {
553 show-status Cancel 0 1
557 proc show-target {target base} {
561 .bot.a.target configure -text ""
565 .bot.a.target configure -text "$target"
567 .bot.a.target configure -text "$target - $base"
571 proc show-logo {v1} {
580 .bot.logo configure -bitmap @${libdir}/bitmaps/book${v1}
581 after 140 [list show-logo $v1]
585 .bot.logo configure -bitmap @${libdir}/bitmaps/book1
594 proc show-status {status b sb} {
601 .bot.a.status configure -text "$status"
603 if {$busy == 0} {set busy 1}
611 .top.service configure -state normal
612 .mid.search configure -state normal
614 .mid.scan configure -state normal
617 configure-disable-e .top.service.m 1
618 } elseif {[z39.$setNo nextResultSetPosition] > 0 &&
619 [z39.$setNo nextResultSetPosition] <= [z39.$setNo resultCount]} {
620 configure-enable-e .top.service.m 1
621 .mid.present configure -state normal
623 configure-disable-e .top.service.m 1
624 .mid.present configure -state disabled
626 if {[winfo exists .scan-window]} {
627 .scan-window.bot.2 configure -state normal
628 .scan-window.bot.4 configure -state normal
631 .top.service configure -state disabled
632 .mid.search configure -state disabled
633 .mid.scan configure -state disabled
634 .mid.present configure -state disabled
636 if {[winfo exists .scan-window]} {
637 .scan-window.bot.2 configure -state disabled
638 .scan-window.bot.4 configure -state disabled
643 proc show-message {msg} {
644 .bot.a.message configure -text "$msg"
647 proc insertWithTags {w text args} {
648 set start [$w index insert]
649 $w insert insert $text
650 foreach tag [$w tag names $start] {
651 $w tag remove $tag $start insert
654 $w tag add $i $start insert
658 proc popup-license {} {
663 wm title $w "License"
669 text $w.top.t -width 80 -height 10 -wrap word -relief flat -borderwidth 0 \
670 -yscrollcommand [list $w.top.s set]
671 scrollbar $w.top.s -command [list $w.top.t yview]
673 pack $w.top.s -side right -fill y
674 pack $w.top.t -expand yes -fill both
676 if {[file readable "${libdir}/LICENSE"]} {
677 set f [open "${libdir}/LICENSE" r]
678 while {[gets $f buf] != -1} {
679 $w.top.t insert end $buf
680 $w.top.t insert end "\n"
684 bottom-buttons $w [list {Close} [list destroy $w]] 1
687 proc about-target {} {
688 set w .about-target-w
693 wm title $w "About target"
697 frame $w.top.a -relief ridge -border 2
698 frame $w.top.p -relief ridge -border 2
700 pack $w.top.a $w.top.p -side top -fill x
702 label $w.top.a.about -text "About"
703 label $w.top.a.irtcl -text $hostid \
704 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
705 pack $w.top.a.about $w.top.a.irtcl -side top
707 set i [z39 targetImplementationName]
708 label $w.top.p.in -text "Implementation name: $i"
709 set i [z39 targetImplementationId]
710 label $w.top.p.ii -text "Implementation id: $i"
711 set i [z39 targetImplementationVersion]
712 label $w.top.p.iv -text "Implementation version: $i"
714 label $w.top.p.op -text "Protocol options: $i"
716 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
718 bottom-buttons $w [list {Close} [list destroy $w]] 1
721 proc about-origin-logo {n} {
723 set w .about-origin-w
724 if {![winfo exists $w]} {
731 $w.top.a.logo configure -bitmap @${libdir}/bitmaps/book$n
732 after 140 [list about-origin-logo $n]
735 proc about-origin {} {
736 set w .about-origin-w
740 if {[winfo exists $w]} {
745 wm title $w "About IrTcl"
749 frame $w.top.a -relief ridge -border 2
750 frame $w.top.p -relief ridge -border 2
752 pack $w.top.a $w.top.p -side top -fill x
754 label $w.top.a.irtcl -text "IrTcl" \
755 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
756 label $w.top.a.logo -bitmap @${libdir}/bitmaps/book1
757 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
760 catch {set i [z39 implementationName]}
761 label $w.top.p.in -text "Implementation name: $i"
762 catch {set i [z39 implementationId]}
763 label $w.top.p.ii -text "Implementation id: $i"
764 catch {set i [z39 implementationVersion]}
765 label $w.top.p.iv -text "Implementation version: $i"
767 label $w.top.p.tk -text "Tk version: $i"
769 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.tk -side top -anchor nw
772 bottom-buttons $w [list {Close} [list destroy $w] \
773 {License} [list popup-license]] 0
776 proc popup-marc {sno no b df} {
777 global displayFormats
780 if {[z39.$sno type $no] != "DB"} {
785 while {[winfo exists .full-marc$b]} {
791 if {![winfo exists $w]} {
796 frame $w.top -relief raised -border 1
797 frame $w.bot -relief raised -border 1
799 pack $w.top -side top -fill both -expand yes
800 pack $w.bot -fill both
802 text $w.top.record -width 60 -height 5 -wrap word -relief flat -borderwidth 0 \
803 -yscrollcommand [list $w.top.s set]
804 scrollbar $w.top.s -command [list $w.top.record yview]
808 $w.top.record tag configure marc-tag -foreground blue
809 $w.top.record tag configure marc-id -foreground red
811 $w.top.record tag configure marc-tag -foreground black
812 $w.top.record tag configure marc-id -foreground black
814 $w.top.record tag configure marc-data -foreground black
815 $w.top.record tag configure marc-head \
816 -font -Adobe-Times-Medium-R-Normal-*-180-* \
817 -background black -foreground white
819 $w.top.record tag configure marc-pref \
820 -font -Adobe-Times-Medium-R-Normal-*-180-* \
822 $w.top.record tag configure marc-text \
823 -font -Adobe-Times-Medium-R-Normal-*-180-* \
825 $w.top.record tag configure marc-it \
826 -font -Adobe-Times-Medium-I-Normal-*-180-* \
829 pack $w.top.s -side right -fill y
830 pack $w.top.record -expand yes -fill both
832 bottom-buttons $w [list \
833 {Close} [list destroy $w] \
837 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m \
839 menu $w.bot.formats.m
840 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 \
841 -padx 3 -pady 3 -side left
843 $w.bot.formats.m delete 0 last
846 foreach f $displayFormats {
847 $w.bot.formats.m add radiobutton -label $f \
848 -variable popupMarcdf -value $i \
849 -command [list popup-marc $sno $no $b 0]
852 $w.top.record delete 0.0 end
853 set recordType [z39.$sno recordType $no]
854 wm title $w "$recordType record #$no"
856 $w.bot.2 configure -command \
857 [list popup-marc $sno [expr $no-1] $b $df]
858 $w.bot.4 configure -command \
859 [list popup-marc $sno [expr $no+1] $b $df]
861 $w.bot.2 configure -state disabled
863 $w.bot.2 configure -state normal
865 if {[z39.$sno type [expr $no+1]] != "DB"} {
866 $w.bot.4 configure -state disabled
868 $w.bot.4 configure -state normal
870 $w.bot.6 configure -command [list popup-marc $sno $no -1 0]
871 set ffunc [lindex $displayFormats $df]
872 set ffunc "display-$ffunc"
874 $ffunc $sno $no $w.top.record 0
877 proc update-target-hotlist {target base} {
880 set olen [llength $hotTargets]
882 foreach e $hotTargets {
883 if {$target == [lindex $e 0] && $base == [lindex $e 1]} {
884 set hotTargets [lreplace $hotTargets $i $i]
889 set hotTargets [linsert $hotTargets 0 [list $target $base]]
890 set-target-hotlist $olen
893 proc delete-target-hotlist {target} {
896 set olen [llength $hotTargets]
898 foreach e $hotTargets {
899 if {$target == [lindex $e 0]} {
900 set hotTargets [lreplace $hotTargets $i $i]
904 set-target-hotlist $olen
907 proc set-target-hotlist {olen} {
912 .top.target.m delete 7 [expr 7+$olen]
914 .top.target.m delete 6 [expr 6+$olen]
918 foreach e $hotTargets {
919 set target [lindex $e 0]
920 set base [lindex $e 1]
922 .top.target.m add command -label "$i $target" -command \
923 [list reopen-target $target {}]
925 .top.target.m add command -label "$i $target - $base" -command \
926 [list reopen-target $target $base]
935 proc reopen-target {target base} {
937 open-target $target $base
938 update-target-hotlist $target $base
941 proc define-target-action {} {
944 set target [.target-define.top.target.entry get]
948 foreach n [array names profile] {
950 destroy .target-define
955 set seq [lindex $profile(Default) 12]
957 dputs $profile(Default)
958 set profile($target) $profile(Default)
959 set profile(Default) [lreplace $profile(Default) 12 12 [incr seq]]
961 protocol-setup $target
962 destroy .target-define
965 proc fail-response {target} {
966 set c [lindex [z39 failInfo] 0]
967 set m [lindex [z39 failInfo] 1]
972 proc connect-response {target base} {
973 dputs "connect-response"
974 show-target $target $base
978 proc open-target {target base} {
984 z39 comstack [lindex $profile($target) 6]
985 z39 protocol [lindex $profile($target) 11]
986 z39 idAuthentication [lindex $profile($target) 3]
987 z39 maximumRecordSize [lindex $profile($target) 4]
988 z39 preferredMessageSize [lindex $profile($target) 5]
989 dputs "maximumRecordSize="
990 dputs [z39 maximumRecordSize]
991 dputs "preferredMessageSize="
992 dputs [z39 preferredMessageSize]
993 show-status Connecting 1 0
995 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
997 z39 databaseNames $base
999 set x [lindex $profile($target) 13]
1003 z39 largeSetLowerBound $x
1005 set x [lindex $profile($target) 14]
1009 z39 smallSetUpperBound $x
1011 set x [lindex $profile($target) 15]
1015 z39 mediumSetPresentNumber $x
1017 set presentChunk [lindex $profile($target) 16]
1018 if {$presentChunk == ""} {
1022 z39 failback [list fail-response $target]
1023 z39 callback [list connect-response $target $base]
1026 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
1029 tkerror $errorMessage
1030 show-status "Not connected" 0 {}
1034 configure-disable-e .top.target.m 0
1035 configure-enable-e .top.target.m 1
1036 configure-enable-e .top.target.m 2
1039 proc close-target {} {
1048 .bot.a.set configure -text ""
1052 show-status {Not connected} 0 0
1055 configure-disable-e .top.target.m 1
1056 configure-disable-e .top.target.m 2
1058 .top.rset.m delete 2 last
1060 .top.rset.m delete 1 last
1062 .top.rset.m add separator
1063 configure-enable-e .top.target.m 0
1066 proc load-set-action {} {
1070 ir-set z39.$setNoLast z39
1072 set fname [.load-set.top.filename.entry get]
1075 show-status Loading 1 {}
1077 z39.$setNoLast loadFile $fname
1079 set no [z39.$setNoLast numberOfRecordsReturned]
1080 add-title-lines $setNoLast $no 1
1082 set l [format "%-4d %7d" $setNoLast $no]
1083 .top.rset.m add command -label $l \
1084 -command [list add-title-lines $setNoLast 10000 1]
1085 show-status Ready 0 {}
1091 set oldFocus [focus]
1095 frame $w.top.filename
1096 pack $w.top.filename -side top -anchor e -pady 2
1098 entry-fields $w.top {filename} \
1100 {load-set-action} {destroy .load-set}
1102 top-down-ok-cancel $w {load-set-action} 1
1106 proc init-request {} {
1113 z39 callback {init-response}
1114 show-status Initializing 1 {}
1115 set err [catch {z39 init} errorMessage]
1117 tkerror $errorMessage
1118 show-status Ready 0 {}
1122 proc init-response {} {
1126 dputs {init-reponse}
1131 if {![z39 initResult]} {
1132 show-status Ready 0 1
1133 set u [z39 userInformationField]
1135 tkerror "Connection rejected by target: $u"
1137 if {[lsearch [z39 options] scan] >= 0} {
1142 show-status Ready 0 1
1146 proc search-request {bflag} {
1155 global elementSetNames
1159 if {[z39 connect] == ""} {
1162 dputs "search-request"
1164 if {!$bflag && $busy} {
1165 dputs "busy: search-request ignored"
1170 show-status Searching 1 0
1171 set delayRequest {search-request 1}
1176 set query [index-query]
1181 set setNo $setNoLast
1182 ir-set z39.$setNo z39
1184 if {[lindex $profile($target) 10] == 1} {
1185 z39.$setNo setName $setNo
1186 dputs "setName=${setNo}"
1188 z39.$setNo setName Default
1189 dputs "setName=Default"
1191 if {[lindex $profile($target) 8] == 1} {
1192 z39.$setNo queryType rpn
1194 if {[lindex $profile($target) 9] == 1} {
1195 z39.$setNo queryType ccl
1199 if {$recordSyntax == "None" } {
1200 z39.$setNo preferredRecordSyntax {}
1202 z39.$setNo preferredRecordSyntax $recordSyntax
1204 if {$elementSetNames == "None" } {
1205 z39.$setNo elementSetNames {}
1206 z39.$setNo smallSetElementSetNames {}
1207 z39.$setNo mediumSetElementSetNames {}
1209 z39.$setNo elementSetNames $elementSetNames
1210 z39.$setNo smallSetElementSetNames $elementSetNames
1211 z39.$setNo mediumSetElementSetNames $elementSetNames
1213 z39 callback {search-response}
1214 z39.$setNo search $query
1215 show-status Searching 1 0
1218 proc scan-copy {y entry} {
1220 set no [$w.top.list nearest $y]
1222 .lines.$entry.e delete 0 end
1223 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
1226 proc scan-request {} {
1233 global curIndexEntry
1234 global queryButtonsFind
1235 global queryInfoFind
1239 dputs "scan-request"
1242 show-status Scanning 1 0
1243 set delayRequest scan-request
1252 set b [lindex $queryButtonsFind $curIndexEntry]
1254 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
1255 set attr "@attr $a $attr"
1257 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
1258 ir-scan z39.scan z39
1260 if {![winfo exists $w]} {
1267 entry $w.top.entry -relief sunken
1268 pack $w.top.entry -fill x -padx 4 -pady 2
1269 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
1270 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
1272 scrollbar $w.top.scroll -orient vertical -border 1
1273 pack $w.top.list -side left -fill both -expand yes
1274 pack $w.top.scroll -side right -fill y
1275 $w.top.scroll config -command [list $w.top.list yview]
1277 bottom-buttons $w [list {Close} [list destroy $w] \
1278 {Up} [list scan-up $attr] \
1279 {Down} [list scan-down $attr]] 0
1280 bind $w.top.list <Up> [list scan-up $attr]
1281 bind $w.top.list <Down> [list scan-down $attr]
1284 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
1285 wm title $w "Scan $title"
1287 z39 callback [list scan-response $attr 0 35]
1288 z39.scan numberOfTermsRequested 5
1289 z39.scan preferredPositionInResponse 1
1290 z39.scan scan "${attr} 0"
1292 show-status Scanning 1 0
1295 proc scan-term-h {attr} {
1303 set nScanTerm [$w.top.entry get]
1304 if {$nScanTerm == $scanTerm} {
1307 set scanTerm $nScanTerm
1308 z39 callback [list scan-response $attr 0 35]
1309 z39.scan numberOfTermsRequested 5
1310 z39.scan preferredPositionInResponse 1
1311 dputs "${attr} \{${scanTerm}\}"
1312 if {$scanTerm == ""} {
1313 z39.scan scan "${attr} 0"
1315 z39.scan scan "${attr} \{${scanTerm}\}"
1317 show-status Scanning 1 0
1320 proc scan-response {attr start toget} {
1327 dputs "In scan-response"
1328 set m [z39.scan numberOfEntriesReturned]
1334 if {![winfo exists .scan-window]} {
1337 dputs "Handling cancel"
1338 if {$delayRequest != ""} {
1343 show-status Ready 0 1
1346 set nScanTerm [$w.top.entry get]
1347 if {$nScanTerm != $scanTerm} {
1348 z39 callback [list scan-response $attr 0 35]
1349 z39.scan numberOfTermsRequested 5
1350 z39.scan preferredPositionInResponse 1
1351 set scanTerm $nScanTerm
1352 dputs "${attr} \{${scanTerm}\}"
1353 if {$scanTerm == ""} {
1354 z39.scan scan "${attr} 0"
1356 z39.scan scan "${attr} \{${scanTerm}\}"
1358 show-status Scanning 1 0
1361 set status [z39.scan scanStatus]
1364 show-status Ready 0 1
1369 for {set i 0} {$i < $m} {incr i} {
1370 set term [lindex [z39.scan scanLine $i] 1]
1371 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1372 $w.top.list insert $i "$nostr $term"
1375 $w.top.list yview $scanView
1377 $w.top.list delete $start end
1378 for {set i 0} {$i < $m} {incr i} {
1379 set term [lindex [z39.scan scanLine $i] 1]
1380 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1381 $w.top.list insert end "$nostr $term"
1385 dputs "Handling cancel"
1387 if {$delayRequest != ""} {
1393 if {$toget > 0 && $m > 1 && $m < $toget} {
1394 set ntoget [expr $toget - $m + 1]
1395 dputs ntoget=$ntoget
1396 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1398 dputs "down continue: $q"
1400 z39.scan numberOfTermsRequested 10
1402 z39.scan numberOfTermsRequested $ntoget
1404 z39.scan preferredPositionInResponse 1
1405 dputs "${attr} \{$q\}"
1406 z39.scan scan "${attr} \{$q\}"
1409 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1410 set ntoget [expr - $toget - $m]
1411 dputs ntoget=$ntoget
1412 z39 callback [list scan-response $attr 0 -$ntoget]
1413 set q [string range [$w.top.list get 0] 8 end]
1414 dputs "up continue: $q"
1416 z39.scan numberOfTermsRequested 10
1417 z39.scan preferredPositionInResponse 11
1419 z39.scan numberOfTermsRequested $ntoget
1420 z39.scan preferredPositionInResponse [incr ntoget]
1422 dputs "${attr} \{$q\}"
1423 z39.scan scan "${attr} \{$q\}"
1426 show-status Ready 0 1
1429 proc scan-down {attr} {
1437 show-status {Scanning down} 1 0
1438 set delayRequest [list scan-down $attr]
1444 set scanView [expr $scanView + 5]
1445 set s [$w.top.list size]
1446 if {$scanView > $s} {
1447 z39 callback [list scan-response $attr [expr $s - 1] 25]
1448 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1450 z39.scan numberOfTermsRequested 10
1451 z39.scan preferredPositionInResponse 1
1452 show-status Scanning 1 0
1453 dputs "${attr} \{$q\}"
1454 z39.scan scan "${attr} \{$q\}"
1457 $w.top.list yview $scanView
1460 proc scan-up {attr} {
1468 show-status Scanning 1 0
1469 set delayRequest [list scan-up $attr]
1475 set scanView [expr $scanView - 5]
1476 if {$scanView < 0} {
1477 z39 callback [list scan-response $attr 0 -25]
1478 set q [string range [$w.top.list get 0] 8 end]
1480 z39.scan numberOfTermsRequested 10
1481 z39.scan preferredPositionInResponse 11
1482 show-status Scanning 1 0
1483 z39.scan scan "${attr} \{$q\}"
1486 $w.top.list yview $scanView
1489 proc search-response {} {
1499 dputs "In search-response"
1501 dputs "Handling cancel"
1503 if {$delayRequest != ""} {
1511 set setMax [z39.$setNo resultCount]
1512 show-status Ready 0 1
1513 set status [z39.$setNo responseStatus]
1514 if {[lindex $status 0] == "NSD"} {
1515 z39.$setNo nextResultSetPosition 0
1516 set code [lindex $status 1]
1517 set msg [lindex $status 2]
1518 set addinfo [lindex $status 3]
1519 tkerror "NSD$code: $msg: $addinfo"
1522 show-message "${setMax} hits"
1527 show-status Ready 0 1
1528 set l [format "%-4d %7d" $setNo $setMax]
1529 .top.rset.m add command -label $l \
1530 -command [list add-title-lines $setNo 10000 1]
1534 set no [z39.$setNo numberOfRecordsReturned]
1535 dputs "Returned $no records, setOffset $setOffset"
1536 add-title-lines $setNo $no $setOffset
1537 set setOffset [expr $setOffset + $no]
1539 set toGet [expr $setMax - $setOffset + 1]
1541 if {$setOffset == 1} {
1543 } elseif {$toGet > $presentChunk} {
1544 set toGet $presentChunk
1546 z39 callback {present-response}
1547 z39.$setNo present $setOffset $toGet
1548 show-status Retrieving 1 0
1552 proc present-more {number} {
1561 dputs "present-more"
1563 show-status Retrieving 1 0
1564 set delayRequest "present-more $number"
1570 dputs "setNo=$setNo"
1573 set setOffset [z39.$setNo nextResultSetPosition]
1574 dputs "setOffest=${setOffset}"
1575 dputs "setNo=${setNo}"
1576 set max [z39.$setNo resultCount]
1577 if {$max < $setOffset} {
1579 dputs "setOffset=$setOffset"
1580 show-status Ready 0 1
1583 if {$number == ""} {
1587 if {$setMax > $max} {
1591 z39 callback {present-response}
1593 set toGet [expr $setMax - $setOffset + 1]
1597 if {$toGet > $presentChunk} {
1598 set toGet $presentChunk
1600 z39.$setNo present $setOffset $toGet
1601 show-status Retrieving 1 0
1604 proc init-title-lines {} {
1605 .data.record delete 0.0 end
1608 proc add-title-lines {setno no offset} {
1609 global displayFormats
1610 global displayFormat
1614 dputs "add-title-lines offset=${offset} no=${no}"
1622 .bot.a.set configure -text $setno
1623 .data.record delete 0.0 end
1625 set ffunc [lindex $displayFormats $displayFormat]
1626 dputs "ffunc=$ffunc"
1627 set ffunc "display-$ffunc"
1628 for {set i 0} {$i < $no} {incr i} {
1629 set o [expr $i + $offset]
1630 set type [z39.$setno type $o]
1632 dputs "no more at $o"
1635 .data.record tag bind r$o <Any-Enter> {}
1636 .data.record tag bind r$o <Any-Leave> {}
1637 set insert0 [.data.record index insert]
1638 $ffunc $setno $o .data.record 1
1639 .data.record tag add r$o $insert0 insert
1640 .data.record tag bind r$o <1> \
1641 [list popup-marc $setno $o 0 0]
1645 show-status Ready 0 1
1649 proc present-response {} {
1657 dputs "In present-response"
1658 set no [z39.$setNo numberOfRecordsReturned]
1659 dputs "Returned $no records, setOffset $setOffset"
1660 add-title-lines $setNo $no $setOffset
1661 set setOffset [expr $setOffset + $no]
1663 dputs "Handling cancel"
1665 if {$delayRequest != ""} {
1670 set status [z39.$setNo responseStatus]
1671 if {[lindex $status 0] == "NSD"} {
1672 show-status Ready 0 1
1673 set code [lindex $status 1]
1674 set msg [lindex $status 2]
1675 set addinfo [lindex $status 3]
1676 tkerror "NSD$code: $msg: $addinfo"
1679 if {$no > 0 && $setOffset <= $setMax} {
1680 dputs "present-request from ${setOffset}"
1681 set toGet [expr $setMax - $setOffset + 1]
1682 if {$toGet > $presentChunk} {
1683 set toGet $presentChunk
1685 z39.$setNo present $setOffset $toGet
1687 show-status Ready 0 1
1691 proc left-cursor {w} {
1692 set i [$w index insert]
1700 proc right-cursor {w} {
1701 set i [$w index insert]
1707 proc bind-fields {list returnAction escapeAction} {
1708 set max [expr [llength $list]-1]
1709 for {set i 0} {$i < $max} {incr i} {
1710 bind [lindex $list $i] <Return> $returnAction
1711 bind [lindex $list $i] <Escape> $escapeAction
1713 bind [lindex $list $i] <Tab> \
1714 [list focus [lindex $list [expr $i+1]]]
1715 bind [lindex $list $i] <Left> \
1716 [list left-cursor [lindex $list $i]]
1717 bind [lindex $list $i] <Right> \
1718 [list right-cursor [lindex $list $i]]
1721 bind [lindex $list $i] <Return> $returnAction
1722 bind [lindex $list $i] <Escape> $escapeAction
1724 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1725 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1726 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1728 focus [lindex $list 0]
1731 proc entry-fields {parent list tlist returnAction escapeAction} {
1734 foreach field $list {
1735 set label ${parent}.${field}.label
1736 set entry ${parent}.${field}.entry
1737 label $label -text [lindex $tlist $i] -anchor e
1738 entry $entry -width 32 -relief sunken
1739 pack $label -side left
1740 pack $entry -side right
1741 lappend alist $entry
1744 bind-fields $alist $returnAction $escapeAction
1747 proc define-target-dialog {} {
1748 set w .target-define
1754 pack $w.top.target \
1755 -side top -anchor e -pady 2
1756 entry-fields $w.top {target} \
1758 {define-target-action} {destroy .target-define}
1759 top-down-ok-cancel $w {define-target-action} 1
1762 proc protocol-setup-delete {target w} {
1764 global settingsChanged
1766 set a [alert "Are you sure you want to delete the target \
1767 definition $target ?"]
1770 unset profile($target)
1771 set settingsChanged 1
1773 delete-target-hotlist $target
1777 proc protocol-setup-action {target w} {
1779 global settingsChanged
1783 set settingsChanged 1
1784 set len [$w.top.databases.list size]
1785 for {set i 0} {$i < $len} {incr i} {
1786 lappend dataBases [$w.top.databases.list get $i]
1788 set wno [lindex $profile($target) 12]
1790 set profile($target) [list [$w.top.description.entry get] \
1791 [$w.top.host.entry get] \
1792 [$w.top.port.entry get] \
1793 [$w.top.idAuthentication.entry get] \
1794 $targetS($target,MRS) \
1795 $targetS($target,PMS) \
1796 $targetS($target,csType) \
1798 $targetS($target,RPN) \
1799 $targetS($target,CCL) \
1800 $targetS($target,ResultSets) \
1801 $targetS($target,protocolType) \
1803 $targetS($target,LSLB) \
1804 $targetS($target,SSUB) \
1805 $targetS($target,MSPN) \
1806 $targetS($target,presentChunk) ]
1809 delete-target-hotlist $target
1810 dputs $profile($target)
1814 proc place-force {window parent} {
1815 set g [wm geometry $parent]
1817 set p1 [string first + $g]
1818 set p2 [string last + $g]
1820 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1821 set y [expr 60+[string range $g [expr $p2 +1] end]]
1822 wm geometry $window +${x}+${y}
1825 proc add-database-action {target w} {
1828 $w.top.databases.list insert end \
1829 [.database-select.top.database.entry get]
1830 destroy .database-select
1833 proc add-database {target wp} {
1836 set w .database-select
1838 set oldFocus [focus]
1844 frame $w.top.database
1846 pack $w.top.database -side top -anchor e -pady 2
1848 entry-fields $w.top {database} \
1849 {{Database to add:}} \
1850 [list add-database-action $target $wp] {destroy .database-select}
1852 top-down-ok-cancel $w [list add-database-action $target $wp] 1
1856 proc delete-database {target w} {
1860 foreach i [$w.top.databases.list curselection] {
1861 set b [$w.top.databases.list get $i]
1864 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1866 foreach i [lsort -decreasing \
1867 [$w.top.databases.list curselection]] {
1868 $w.top.databases.list delete $i
1873 proc protocol-setup {target} {
1878 while {[winfo exists .setup-$bno]} {
1885 wm title $w "Setup $target"
1889 if {$target == ""} {
1893 dputs $profile($target)
1895 frame $w.top.description
1898 frame $w.top.idAuthentication
1899 frame $w.top.cs-type -relief ridge -border 2
1900 frame $w.top.protocol -relief ridge -border 2
1901 frame $w.top.query -relief ridge -border 2
1902 frame $w.top.databases -relief ridge -border 2
1904 # Maximum/preferred/idAuth ...
1905 pack $w.top.description $w.top.host $w.top.port \
1906 $w.top.idAuthentication -side top -anchor e -pady 2
1908 entry-fields $w.top {description host port idAuthentication } \
1909 {{Description:} {Host:} {Port:} {Id Authentication:}} \
1910 [list protocol-setup-action $target $w] [list destroy $w]
1912 foreach sub {description host port idAuthentication} {
1914 bind $w.top.$sub.entry <Control-a> [list add-database $target $w]
1915 bind $w.top.$sub.entry <Control-d> [list delete-database $target $w]
1917 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1918 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1919 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1920 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1921 set targetS($target,csType) [lindex $profile($target) 6]
1922 set targetS($target,RPN) [lindex $profile($target) 8]
1923 set targetS($target,CCL) [lindex $profile($target) 9]
1924 set targetS($target,ResultSets) [lindex $profile($target) 10]
1925 set targetS($target,protocolType) [lindex $profile($target) 11]
1926 if {$targetS($target,protocolType) == ""} {
1927 set targetS($target,protocolType) Z39
1929 set targetS($target,LSLB) [lindex $profile($target) 13]
1930 set targetS($target,SSUB) [lindex $profile($target) 14]
1931 set targetS($target,MSPN) [lindex $profile($target) 15]
1932 set targetS($target,presentChunk) [lindex $profile($target) 16]
1933 set targetS($target,MRS) [lindex $profile($target) 4]
1934 set targetS($target,PMS) [lindex $profile($target) 5]
1936 pack $w.top.databases -side left -pady 2 -padx 2 -expand yes -fill both
1938 label $w.top.databases.label -text "Databases"
1939 button $w.top.databases.add -text Add \
1940 -command [list add-database $target $w]
1941 button $w.top.databases.delete -text Delete \
1942 -command [list delete-database $target $w]
1944 listbox $w.top.databases.list -geometry 14x6 \
1945 -yscrollcommand "$w.top.databases.scroll set"
1947 listbox $w.top.databases.list -width 14 -height 5\
1948 -yscrollcommand "$w.top.databases.scroll set"
1950 scrollbar $w.top.databases.scroll -orient vertical -border 1
1951 pack $w.top.databases.label -side top -fill x \
1953 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1955 pack $w.top.databases.list -side left -fill both -expand yes \
1957 pack $w.top.databases.scroll -side right -fill y \
1959 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1961 foreach b [lindex $profile($target) 7] {
1962 $w.top.databases.list insert end $b
1966 pack $w.top.cs-type -pady 2 -padx 2 -side top -fill x
1968 label $w.top.cs-type.label -text "Transport"
1969 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1970 -variable targetS($target,csType) -value tcpip
1971 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1972 -variable targetS($target,csType) -value mosi
1974 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1975 -padx 2 -side top -fill x
1978 pack $w.top.protocol -pady 2 -padx 2 -side top -fill x
1980 label $w.top.protocol.label -text "Protocol"
1981 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1982 -variable targetS($target,protocolType) -value Z39
1983 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1984 -variable targetS($target,protocolType) -value SR
1986 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1987 -padx 2 -side top -fill x
1990 pack $w.top.query -pady 2 -padx 2 -side top -fill x
1992 label $w.top.query.label -text "Query support"
1993 checkbutton $w.top.query.c1 -text "RPN query" -anchor w \
1994 -variable targetS($target,RPN)
1995 checkbutton $w.top.query.c2 -text "CCL query" -anchor w \
1996 -variable targetS($target,CCL)
1997 checkbutton $w.top.query.c3 -text "Result sets" -anchor w \
1998 -variable targetS($target,ResultSets)
2000 pack $w.top.query.label -side top
2001 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
2002 -padx 2 -side top -fill x
2005 bottom-buttons $w [list {Ok} [list protocol-setup-action $target $w] \
2006 {Delete} [list protocol-setup-delete $target $w] \
2007 {Advanced} [list advanced-setup $target $bno] \
2008 {Cancel} [list destroy $w]] 0
2012 proc advanced-setup {target b} {
2016 set w .advanced-setup-$b
2020 wm title $w "Advanced setup $target"
2024 if {$target == ""} {
2029 frame $w.top.largeSetLowerBound
2030 frame $w.top.smallSetUpperBound
2031 frame $w.top.mediumSetPresentNumber
2032 frame $w.top.presentChunk
2033 frame $w.top.maximumRecordSize
2034 frame $w.top.preferredMessageSize
2036 pack $w.top.largeSetLowerBound $w.top.smallSetUpperBound \
2037 $w.top.mediumSetPresentNumber $w.top.presentChunk \
2038 $w.top.maximumRecordSize $w.top.preferredMessageSize \
2039 -side top -anchor e -pady 2
2041 entry-fields $w.top {largeSetLowerBound smallSetUpperBound \
2042 mediumSetPresentNumber presentChunk maximumRecordSize \
2043 preferredMessageSize} \
2044 {{Large Set Lower Bound:} {Small Set Upper Bound:} \
2045 {Medium Set Present Number:} {Present Chunk:} \
2046 {Maximum Record Size:} {Preferred Message Size:}} \
2047 [list advanced-setup-action $target $b] [list destroy $w]
2049 $w.top.largeSetLowerBound.entry insert 0 $targetS($target,LSLB)
2050 $w.top.smallSetUpperBound.entry insert 0 $targetS($target,SSUB)
2051 $w.top.mediumSetPresentNumber.entry insert 0 $targetS($target,MSPN)
2052 $w.top.presentChunk.entry insert 0 $targetS($target,presentChunk)
2053 $w.top.maximumRecordSize.entry insert 0 $targetS($target,MRS)
2054 $w.top.preferredMessageSize.entry insert 0 $targetS($target,PMS)
2056 bottom-buttons $w [list {Ok} [list advanced-setup-action $target $b] \
2057 {Cancel} [list destroy $w]] 0
2060 proc advanced-setup-action {target b} {
2061 set w .advanced-setup-$b
2064 set targetS($target,LSLB) [$w.top.largeSetLowerBound.entry get]
2065 set targetS($target,SSUB) [$w.top.smallSetUpperBound.entry get]
2066 set targetS($target,MSPN) [$w.top.mediumSetPresentNumber.entry get]
2067 set targetS($target,presentChunk) [$w.top.presentChunk.entry get]
2068 set targetS($target,MRS) [$w.top.maximumRecordSize.entry get]
2069 set targetS($target,PMS) [$w.top.preferredMessageSize.entry get]
2071 dputs "advanced-setup-action"
2075 proc database-select-action {} {
2076 set w .database-select.top
2078 foreach indx [$w.databases.list curselection] {
2079 lappend b [$w.databases.list get $indx]
2082 z39 databaseNames $b
2084 destroy .database-select
2087 proc database-select {} {
2088 set w .database-select
2093 set oldFocus [focus]
2098 frame $w.top.databases -relief ridge -border 2
2100 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
2102 label $w.top.databases.label -text "List"
2103 listbox $w.top.databases.list -width 20 -height 6 \
2104 -yscrollcommand "$w.top.databases.scroll set"
2105 scrollbar $w.top.databases.scroll -orient vertical -border 1
2106 pack $w.top.databases.label -side top -fill x \
2108 pack $w.top.databases.list -side left -fill both -expand yes \
2110 pack $w.top.databases.scroll -side right -fill y \
2112 $w.top.databases.scroll config -command "$w.top.databases.list yview"
2114 foreach b [lindex $profile($hostid) 7] {
2115 $w.top.databases.list insert end $b
2117 top-down-ok-cancel $w {database-select-action} 1
2121 proc cascade-target-list {} {
2124 foreach sub [winfo children .top.target.m.clist] {
2127 .top.target.m.clist delete 0 last
2128 foreach n [lsort [array names profile]] {
2129 if {$n != "Default"} {
2130 set nl [lindex $profile($n) 12]
2131 if {[llength [lindex $profile($n) 7]] > 1} {
2132 .top.target.m.clist add cascade -label $n \
2133 -menu .top.target.m.clist.$nl
2134 menu .top.target.m.clist.$nl
2135 foreach b [lindex $profile($n) 7] {
2136 .top.target.m.clist.$nl add command -label $b \
2137 -command [list reopen-target $n $b]
2140 .top.target.m.clist add command -label $n \
2141 -command [list reopen-target $n {}]
2145 .top.target.m.slist delete 0 last
2146 foreach n [lsort [array names profile]] {
2147 .top.target.m.slist add command -label $n \
2148 -command [list protocol-setup $n]
2152 proc query-select {i} {
2153 global queryButtonsFind
2154 global queryInfoFind
2158 set queryInfoFind [lindex $queryInfo $i]
2159 set queryButtonsFind [lindex $queryButtons $i]
2161 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2164 proc query-new-action {} {
2168 global settingsChanged
2170 set settingsChanged 1
2171 lappend queryTypes [.query-new.top.index.entry get]
2172 lappend queryButtons {}
2173 lappend queryInfo {}
2183 set oldFocus [focus]
2188 -side top -anchor e -pady 2
2189 entry-fields $w.top index \
2191 query-new-action {destroy .query-new}
2192 top-down-ok-cancel $w query-new-action 1
2196 proc query-delete-action {queryNo} {
2200 global settingsChanged
2202 set settingsChanged 1
2204 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
2205 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
2206 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
2207 destroy .query-delete
2211 proc query-delete {queryNo} {
2219 set n [lindex $queryTypes $queryNo]
2221 label $w.top.warning -bitmap warning
2222 message $w.top.quest -text "Are you sure you want to delete the \
2223 query type $n ?" -aspect 300
2224 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
2225 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
2226 {Cancel} [list destroy $w]] 1
2229 proc cascade-query-list {} {
2231 set w .top.options.m.query
2234 $w.slist delete 0 last
2235 foreach n $queryTypes {
2236 $w.slist add command -label $n -command [list query-setup $i]
2241 $w.clist delete 0 last
2242 foreach n $queryTypes {
2243 $w.clist add command -label $n -command [list query-select $i]
2247 $w.dlist delete 0 last
2248 foreach n $queryTypes {
2249 $w.dlist add command -label $n -command [list query-delete $i]
2254 proc save-geometry {} {
2255 global windowGeometry
2258 global displayFormat
2261 global elementSetNames
2264 set windowGeometry(.) [wm geometry .]
2266 if {[catch {set f [open ~/.clientrc.tcl w]}]} {
2269 if {$hostid != "Default"} {
2270 puts $f "set hostid $hostid"
2271 set b [z39 databaseNames]
2272 puts $f "set hostbase $b"
2274 puts $f "set hotTargets \{ $hotTargets \}"
2275 puts $f "set textWrap $textWrap"
2276 puts $f "set displayFormat $displayFormat"
2277 puts $f "set popupMarcdf $popupMarcdf"
2278 puts $f "set recordSyntax $recordSyntax"
2279 puts $f "set elementSetNames $elementSetNames"
2280 foreach n [array names windowGeometry] {
2281 puts -nonewline $f "set \{windowGeometry($n)\} \{"
2282 puts -nonewline $f $windowGeometry($n)
2288 proc save-settings {} {
2291 global settingsChanged
2296 if {![file writable "${libdir}/clientrc.tcl"]} {
2297 set a [alert "Cannot open ${libdir}/clientrc.tcl for writing. Do you \
2298 wish to save clientrc.tcl in the current directory instead?"]
2302 set f [open "clientrc.tcl" w]
2304 set f [open "${libdir}/clientrc.tcl" w]
2306 puts $f "# Setup file"
2308 foreach n [array names profile] {
2309 puts -nonewline $f "set \{profile($n)\} \{"
2310 puts -nonewline $f $profile($n)
2313 puts -nonewline $f "set queryTypes \{"
2314 puts -nonewline $f $queryTypes
2317 puts -nonewline $f "set queryButtons \{"
2318 puts -nonewline $f $queryButtons
2321 puts -nonewline $f "set queryInfo \{"
2322 puts -nonewline $f $queryInfo
2325 set settingsChanged 0
2334 set oldFocus [focus]
2338 label $w.top.warning -bitmap warning
2339 message $w.top.message -text $ask -aspect 300 \
2340 -font -Adobe-Times-Medium-R-Normal-*-180-*
2342 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
2345 top-down-ok-cancel $w {alert-action} 1
2350 proc alert-action {} {
2356 proc exit-action {} {
2357 global settingsChanged
2359 if {$settingsChanged} {
2360 set a [alert "you haven't saved your settings. Do you wish to save?"]
2369 proc listbuttonaction {w name h user i} {
2370 $w configure -text [lindex $name 0]
2371 $h [lindex $name 1] $user $i
2374 proc listbuttonx {button no names handle user} {
2375 if {[winfo exists $button]} {
2376 $button configure -text [lindex [lindex $names $no] 0]
2377 ${button}.m delete 0 last
2379 menubutton $button -text [lindex [lindex $names $no] 0] \
2380 -width 10 -menu ${button}.m -relief raised -border 1
2384 foreach name $names {
2385 ${button}.m add command -label [lindex $name 0] \
2386 -command [list listbuttonaction ${button} $name \
2392 proc listbutton {button no names} {
2393 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
2394 -relief raised -border 1
2396 foreach name $names {
2397 ${button}.m add command -label $name \
2398 -command [list ${button} configure -text $name]
2402 proc listbuttonv-action {button var names i} {
2405 set $var [lindex $names [expr $i+1]]
2406 $button configure -text [lindex $names $i]
2409 proc listbuttonv {button var names} {
2413 eval "set val $$var"
2414 set l [llength $names]
2415 for {set i 1} {$i < $l} {incr i 2} {
2416 if {$val == [lindex $names $i]} {
2418 set n [lindex $names $i]
2422 if {[winfo exists $button]} {
2423 $button configure -text $n
2426 menubutton $button -text $n -menu ${button}.m \
2427 -relief raised -border 1
2429 for {set i 0} {$i < $l} {incr i 2} {
2430 ${button}.m add command -label [lindex $names $i] \
2431 -command [list listbuttonv-action $button $var $names $i]
2435 proc query-add-index-action {queryNo} {
2439 global queryButtonsTmp
2441 set newI [.query-add-index.top.index.entry get]
2442 lappend queryInfoTmp [list $newI {}]
2443 $w.top.index.list insert end $newI
2444 destroy .query-add-index
2445 #destroy $w.top.lines
2446 #frame $w.top.lines -relief ridge -border 2
2447 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2448 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2451 proc query-add-line {queryNo} {
2455 global queryButtonsTmp
2457 lappend queryButtonsTmp {I 0}
2459 #destroy $w.top.lines
2460 #frame $w.top.lines -relief ridge -border 2
2461 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2462 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2465 proc query-del-line {queryNo} {
2469 global queryButtonsTmp
2471 set l [llength $queryButtonsTmp]
2476 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
2477 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2480 proc query-add-index {queryNo} {
2481 set w .query-add-index
2484 set oldFocus [focus]
2485 place-force $w .query-setup
2489 -side top -anchor e -pady 2
2490 entry-fields $w.top {index} \
2492 [list query-add-index-action $queryNo] [list destroy $w]
2493 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
2497 proc query-setup-action {queryNo} {
2500 global queryButtonsTmp
2502 global queryButtonsFind
2503 global queryInfoFind
2505 global settingsChanged
2507 set settingsChanged 1
2509 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
2511 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
2513 set queryInfoFind $queryInfoTmp
2514 set queryButtonsFind $queryButtonsTmp
2516 destroy .query-setup
2517 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2520 proc activate-e-index {value no i} {
2521 global queryButtonsTmp
2522 global queryIndexTmp
2524 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
2525 dputs $queryButtonsTmp
2526 set queryIndexTmp $i
2529 proc activate-index {value no i} {
2530 global queryButtonsFind
2532 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
2534 dputs "queryButtonsFind $queryButtonsFind"
2537 proc update-attr {} {
2539 listbuttonv $w.top.relation.b relationTmpValue\
2540 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
2541 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
2542 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
2543 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
2544 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
2545 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
2546 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
2547 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
2548 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
2549 {local-number} 107 {string} 108 {numeric string} 109}
2550 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2551 {Left} 2 {Left and right} 3 {No truncation} 100 \
2552 {Process #} 101 {Re-1} 102 {Re-2} 103}
2553 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2554 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2557 proc use-attr {init} {
2569 {BNB card number} 10
2570 {BGF(sic) number} 11
2572 {Dewey classification} 13
2573 {UDC classification} 14
2574 {Bliss classification} 15
2576 {NLM call number} 17
2577 {NAL call number} 18
2578 {MOS call number} 19
2579 {Local classification} 20
2580 {Subject heading} 21
2582 {BDI-index-subject} 23
2586 {LC-subject-heading} 27
2587 {RVM-subject-heading} 28
2588 {Local subject index} 29
2590 {Date of publication} 31
2591 {Date of acquisition} 32
2593 {Title-collective} 34
2596 {Title-added-title-page} 37
2600 {Title-other-variant} 41
2602 {Title-abbreviated} 43
2606 {Subject-subdivision} 47
2607 {Number-natl-bibliography} 48
2608 {Number-legal-deposit} 49
2609 {Number-govt-publication} 50
2610 {Number-publisher-for-music} 51
2612 {Number-local-call} 53
2614 {Code-geographic-area} 55
2615 {Code-institution} 56
2617 {Name-geographic} 58
2618 {Place-publication} 59
2620 {Microform-generation} 61
2627 {Author-name-personal} 1004
2628 {Author-name-corporate} 1005
2629 {Author-name-conference} 1006
2630 {Identifier-standard} 1007
2631 {Subject-LC-children's} 1008
2632 {Subject-name-personal} 1009
2634 {Date/time added to database} 1011
2635 {Date/time last modified} 1012
2636 {Authority/format identifier} 1013
2638 {Concept-reference} 1015
2640 {Server choice} 1017
2642 {Record source} 1019
2645 {Geographic class} 1022
2649 {Related periodical} 1026
2650 {Report number} 1027
2652 {Thematic number} 1030
2653 {Material type} 1031
2661 set l [llength $attr]
2666 for {set i 0} {$i < $l} {incr i} {
2667 $w.top.use.list insert end [lindex $attr $i]
2669 if {$useTmpValue == [lindex $attr $i]} {
2675 $w.top.use.list selection clear 0 end
2676 $w.top.use.list selection set $s $s
2678 $w.top.use.list select from $s
2679 $w.top.use.list select to $s
2685 $w.top.use.list yview $s
2687 set lno [lindex [$w.top.use.list curselection] 0]
2688 set i [expr $lno+$lno+1]
2689 set useTmpValue [lindex $attr $i]
2690 dputs "useTmpValue=$useTmpValue"
2694 proc index-setup-action {oldAttr queryNo indexNo} {
2695 set attr [lindex $oldAttr 0]
2698 global relationTmpValue
2699 global structureTmpValue
2700 global truncationTmpValue
2701 global completenessTmpValue
2702 global positionTmpValue
2707 dputs "index-setup-action"
2708 dputs "queryNo $queryNo"
2709 dputs "indexNo $indexNo"
2710 if {$useTmpValue > 0} {
2711 lappend attr "1=$useTmpValue"
2713 if {$relationTmpValue > 0} {
2714 lappend attr "2=$relationTmpValue"
2716 if {$positionTmpValue > 0} {
2717 lappend attr "3=$positionTmpValue"
2719 if {$structureTmpValue > 0} {
2720 lappend attr "4=$structureTmpValue"
2722 if {$truncationTmpValue > 0} {
2723 lappend attr "5=$truncationTmpValue"
2725 if {$completenessTmpValue > 0} {
2726 lappend attr "6=$completenessTmpValue"
2728 dputs "new attr $attr"
2729 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2730 destroy .index-setup
2733 proc index-setup {attr queryNo indexNo} {
2736 global relationTmpValue
2737 global structureTmpValue
2738 global truncationTmpValue
2739 global completenessTmpValue
2740 global positionTmpValue
2742 set relationTmpValue 0
2743 set truncationTmpValue 0
2744 set structureTmpValue 0
2745 set positionTmpValue 0
2746 set completenessTmpValue 0
2752 set n [lindex $attr 0]
2753 wm title $w "Index setup $n"
2757 set len [llength $attr]
2758 for {set i 1} {$i < $len} {incr i} {
2759 set q [lindex $attr $i]
2760 set l [string first = $q]
2762 set t [string range $q 0 [expr $l - 1]]
2763 set v [string range $q [expr $l + 1] end]
2766 { set useTmpValue $v }
2768 { set relationTmpValue $v }
2770 { set positionTmpValue $v }
2772 { set structureTmpValue $v }
2774 { set truncationTmpValue $v }
2776 { set completenessTmpValue $v }
2781 frame $w.top.use -relief ridge -border 2
2782 frame $w.top.relation -relief ridge -border 2
2783 frame $w.top.position -relief ridge -border 2
2784 frame $w.top.structure -relief ridge -border 2
2785 frame $w.top.truncation -relief ridge -border 2
2786 frame $w.top.completeness -relief ridge -border 2
2792 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2794 label $w.top.use.label -text "Use"
2796 listbox $w.top.use.list -width 26 \
2797 -yscrollcommand "$w.top.use.scroll set"
2799 listbox $w.top.use.list -geometry 26x10 \
2800 -yscrollcommand "$w.top.use.scroll set"
2802 scrollbar $w.top.use.scroll -orient vertical -border 1
2803 pack $w.top.use.label -side top -fill x \
2805 pack $w.top.use.list -side left -fill both -expand yes \
2807 pack $w.top.use.scroll -side right -fill y \
2809 $w.top.use.scroll config -command "$w.top.use.list yview"
2813 # Relation Attributes
2815 pack $w.top.relation -pady 6 -padx 6 -side top
2816 label $w.top.relation.label -text "Relation" -width 18
2818 pack $w.top.relation.label $w.top.relation.b -fill x
2820 # Position Attributes
2822 pack $w.top.position -pady 6 -padx 6 -side top
2823 label $w.top.position.label -text "Position" -width 18
2825 pack $w.top.position.label $w.top.position.b -fill x
2827 # Structure Attributes
2829 pack $w.top.structure -pady 6 -padx 6 -side top
2830 label $w.top.structure.label -text "Structure" -width 18
2832 pack $w.top.structure.label $w.top.structure.b -fill x
2834 # Truncation Attributes
2836 pack $w.top.truncation -pady 6 -padx 6 -side top
2837 label $w.top.truncation.label -text "Truncation" -width 18
2839 pack $w.top.truncation.label $w.top.truncation.b -fill x
2841 # Completeness Attributes
2843 pack $w.top.completeness -pady 6 -padx 6 -side top
2844 label $w.top.completeness.label -text "Completeness" -width 18
2846 pack $w.top.completeness.label $w.top.completeness.b -fill x
2849 bottom-buttons $w [list \
2850 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2851 {Cancel} [list destroy $w]] 0
2855 proc query-edit-index {queryNo} {
2859 set i [lindex [$w.top.index.list curselection] 0]
2863 set attr [lindex $queryInfoTmp $i]
2864 dputs "Editing no $i $attr"
2865 index-setup $attr $queryNo $i
2868 proc query-delete-index {queryNo} {
2870 global queryButtonsTmp
2873 set i [lindex [$w.top.index.list curselection] 0]
2877 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2878 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2879 $w.top.index.list delete $i
2882 proc query-setup {queryNo} {
2888 global queryButtonsTmp
2890 global queryIndexTmp
2893 set queryName [lindex $queryTypes $queryNo]
2894 set queryInfoTmp [lindex $queryInfo $queryNo]
2895 set queryButtonsTmp [lindex $queryButtons $queryNo]
2900 wm title $w "Query setup $queryName"
2904 frame $w.top.lines -relief ridge -border 2
2906 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2910 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2912 button $w.top.lines.add -text "Add" \
2913 -command [list query-add-line $queryNo]
2914 button $w.top.lines.del -text "Remove" \
2915 -command [list query-del-line $queryNo]
2917 pack $w.top.lines.del -fill x -side bottom
2918 pack $w.top.lines.add -fill x -pady 10 -side bottom
2922 frame $w.top.index -relief ridge -border 2
2923 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2925 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2926 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2927 -command [list $w.top.index.list yview]
2928 bind $w.top.index.list <Double-1> [list query-edit-index $queryNo]
2930 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2931 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2934 $w.top.index.list selection clear 0 end
2935 $w.top.index.list selection set 0 0
2937 $w.top.index.list select from 0
2938 $w.top.index.list select to 0
2941 foreach x $queryInfoTmp {
2942 $w.top.index.list insert end [lindex $x 0]
2946 bottom-buttons $w [list \
2947 Ok [list query-setup-action $queryNo] \
2948 Add [list query-add-index $queryNo] \
2949 Edit [list query-edit-index $queryNo] \
2950 Delete [list query-delete-index $queryNo] \
2951 Cancel [list destroy $w]] 0
2954 proc index-clear {} {
2955 global queryButtonsFind
2958 foreach b $queryButtonsFind {
2959 .lines.$i.e delete 0 end
2964 proc index-query {} {
2965 global queryButtonsFind
2966 global queryInfoFind
2971 foreach b $queryButtonsFind {
2972 set term [string trim [.lines.$i.e get]]
2974 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
2977 set len [string length $term]
2981 if {[string index $term 0] == ">"} {
2982 if {[string index $term 1] == "=" } {
2983 set term [string trim [string range $term 2 $len]]
2986 set term [string trim [string range $term 1 $len]]
2989 } elseif {[string index $term 0] == "<"} {
2990 if {[string index $term 1] == "=" } {
2991 set term [string trim [string range $term 2 $len]]
2993 } elseif {[string index $term 1] == ">"} {
2994 set term [string trim [string range $term 2 $len]]
2997 set term [string trim [string range $term 1 $len]]
3002 set len [string length $term]
3006 if {[string index $term $len] == "?"} {
3008 set term [string range $term 0 [expr $len - 1]]
3010 if {[string index $term 0] == "?"} {
3012 set term [string range $term 1 end]
3014 set term "\{${term}\}"
3015 if {$right && $left} {
3016 set term "@attr 5=3 ${term}"
3018 set term "@attr 5=1 ${term}"
3020 set term "@attr 5=2 ${term}"
3022 if {$relation != ""} {
3023 set term "@attr 2=${relation} ${term}"
3026 set term "@attr $a ${term}"
3029 set qs "@and ${qs} ${term}"
3040 proc index-focus-in {w i} {
3041 global curIndexEntry
3044 $w.$i configure -background red
3046 set curIndexEntry $i
3049 proc index-lines {w realOp buttonInfo queryInfo handle} {
3051 foreach b $buttonInfo {
3052 if {! [winfo exists $w.$i]} {
3054 frame $w.$i -border 0
3056 frame $w.$i -background white -border 1
3059 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
3062 if {! [winfo exists $w.$i.e]} {
3063 entry $w.$i.e -width 32 -relief sunken -border 1
3064 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
3065 bind $w.$i.e <FocusOut> [list $w.$i configure \
3067 pack $w.$i.l -side left
3068 pack $w.$i.e -side left -fill x -expand yes
3069 pack $w.$i -side top -fill x -padx 2 -pady 2
3071 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
3072 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
3074 bind $w.$i.e <Return> {search-request 0}
3077 pack $w.$i.l -side left
3078 pack $w.$i -side top -fill x -padx 2 -pady 2
3083 while {[winfo exists $w.$j]} {
3095 bind $w.$j.e <Tab> "focus $w.$k.e"
3101 bind $w.$i.e <Tab> "focus $w.0.e"
3107 proc search-fields {w buttondefs} {
3109 foreach buttondef $buttondefs {
3110 frame $w.$i -background white
3112 listbutton $w.$i.l 0 $buttondef
3113 entry $w.$i.e -width 32 -relief sunken
3115 pack $w.$i.l -side left
3116 pack $w.$i.e -side left -fill x -expand yes
3118 pack $w.$i -side top -fill x -padx 2 -pady 2
3120 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
3121 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
3129 bind $w.$j.e <Tab> "focus $w.$k.e \n
3130 $w.$k configure -background red \n
3131 $w.$j configure -background white"
3134 bind $w.$i.e <Tab> "focus $w.0.e \n
3135 $w.0 configure -background red \n
3136 $w.$i configure -background white"
3138 $w.0 configure -background red
3141 if {[info exists windowGeometry(.)]} {
3142 set g $windowGeometry(.)
3150 frame .top -border 1 -relief raised
3151 frame .lines -border 1 -relief raised
3152 frame .mid -border 1 -relief raised
3153 frame .data -border 1 -relief raised
3154 frame .bot -border 1 -relief raised
3155 pack .top .lines .mid -side top -fill x
3156 pack .data -side top -fill both -expand yes
3159 menubutton .top.file -text "File" -menu .top.file.m
3161 .top.file.m add command -label "Save settings" -command {save-settings}
3162 .top.file.m add separator
3163 .top.file.m add command -label "Exit" -command {exit-action}
3165 menubutton .top.target -text "Target" -menu .top.target.m
3167 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
3168 .top.target.m add command -label "Disconnect" -command {close-target}
3169 .top.target.m add command -label "About" -command {about-target}
3170 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
3171 .top.target.m add command -label "Setup new" -command {define-target-dialog}
3172 .top.target.m add separator
3173 set-target-hotlist 0
3175 configure-disable-e .top.target.m 1
3176 configure-disable-e .top.target.m 2
3178 menu .top.target.m.clist
3179 menu .top.target.m.slist
3182 menubutton .top.service -text "Service" -menu .top.service.m
3184 .top.service.m add command -label "Database" -command {database-select}
3185 .top.service.m add cascade -label "Present" -menu .top.service.m.present
3186 menu .top.service.m.present
3187 .top.service.m.present add command -label "10 More" \
3188 -command [list present-more 10]
3189 .top.service.m.present add command -label "All" \
3190 -command [list present-more {}]
3191 .top.service.m add command -label "Search" -command {search-request 0}
3192 .top.service.m add command -label "Scan" -command {scan-request}
3194 .top.service configure -state disabled
3196 menubutton .top.rset -text "Set" -menu .top.rset.m
3198 .top.rset.m add command -label "Load" -command {load-set}
3199 .top.rset.m add separator
3201 menubutton .top.options -text "Options" -menu .top.options.m
3203 .top.options.m add cascade -label "Query" -menu .top.options.m.query
3204 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
3205 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
3206 .top.options.m add cascade -label "Syntax" -menu .top.options.m.syntax
3207 .top.options.m add cascade -label "Elements" -menu .top.options.m.elements
3209 menu .top.options.m.query
3210 .top.options.m.query add cascade -label "Select" \
3211 -menu .top.options.m.query.clist
3212 .top.options.m.query add cascade -label "Edit" \
3213 -menu .top.options.m.query.slist
3214 .top.options.m.query add command -label "New" \
3215 -command {query-new}
3216 .top.options.m.query add cascade -label "Delete" \
3217 -menu .top.options.m.query.dlist
3219 menu .top.options.m.query.slist
3220 menu .top.options.m.query.clist
3221 menu .top.options.m.query.dlist
3224 menu .top.options.m.formats
3226 foreach f $displayFormats {
3227 .top.options.m.formats add radiobutton -label $f -value $i \
3228 -command [list set-display-format $i] -variable displayFormat
3232 menu .top.options.m.wrap
3233 .top.options.m.wrap add radiobutton -label "Character" \
3234 -value char -variable textWrap -command {set-wrap char}
3235 .top.options.m.wrap add radiobutton -label "Word" \
3236 -value word -variable textWrap -command {set-wrap word}
3237 .top.options.m.wrap add radiobutton -label "None" \
3238 -value none -variable textWrap -command {set-wrap none}
3240 menu .top.options.m.syntax
3241 .top.options.m.syntax add radiobutton -label "None" \
3242 -value None -variable recordSyntax
3243 .top.options.m.syntax add separator
3244 .top.options.m.syntax add radiobutton -label "USMARC" \
3245 -value USMARC -variable recordSyntax
3246 .top.options.m.syntax add radiobutton -label "UNIMARC" \
3247 -value UNIMARC -variable recordSyntax
3248 .top.options.m.syntax add radiobutton -label "UKMARC" \
3249 -value UKMARC -variable recordSyntax
3250 .top.options.m.syntax add radiobutton -label "DANMARC" \
3251 -value DANMARC -variable recordSyntax
3252 .top.options.m.syntax add radiobutton -label "FINMARC" \
3253 -value FINMARC -variable recordSyntax
3254 .top.options.m.syntax add radiobutton -label "NORMARC" \
3255 -value NORMARC -variable recordSyntax
3256 .top.options.m.syntax add radiobutton -label "PICAMARC" \
3257 -value PICAMARC -variable recordSyntax
3258 .top.options.m.syntax add separator
3259 .top.options.m.syntax add radiobutton -label "SUTRS" \
3260 -value SUTRS -variable recordSyntax
3261 .top.options.m.syntax add separator
3262 .top.options.m.syntax add radiobutton -label "GRS1" \
3263 -value GRS1 -variable recordSyntax
3265 menu .top.options.m.elements
3266 .top.options.m.elements add radiobutton -label "Unspecified" \
3267 -value None -variable elementSetNames
3268 .top.options.m.elements add radiobutton -label "Full" \
3269 -value F -variable elementSetNames
3270 .top.options.m.elements add radiobutton -label "Brief" \
3271 -value B -variable elementSetNames
3273 menubutton .top.help -text "Help" -menu .top.help.m
3276 .top.help.m add command -label "Help on help" \
3277 -command {tkerror "Help on help not available. Sorry"}
3278 .top.help.m add command -label "About" -command {about-origin}
3280 pack .top.file .top.target .top.service .top.rset .top.options -side left
3281 pack .top.help -side right
3283 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
3285 button .mid.search -text Search -command {search-request 0} \
3287 button .mid.scan -text Scan \
3288 -command scan-request -state disabled
3289 button .mid.present -text {Present} -command [list present-more 10] \
3292 button .mid.clear -text Clear -command index-clear
3293 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
3296 text .data.record -height 2 -width 20 -wrap none -borderwidth 0 -relief flat \
3297 -yscrollcommand [list .data.scroll set] -wrap $textWrap
3298 scrollbar .data.scroll -command [list .data.record yview]
3300 .data.record configure -takefocus 0
3301 .data.scroll configure -takefocus 0
3303 pack .data.scroll -side right -fill y
3304 pack .data.record -expand yes -fill both
3308 .data.record tag configure marc-tag -foreground blue
3309 .data.record tag configure marc-id -foreground red
3311 .data.record tag configure marc-tag -foreground black
3312 .data.record tag configure marc-id -foreground black
3314 .data.record tag configure marc-data -foreground black
3315 .data.record tag configure marc-head \
3316 -font -Adobe-Times-Bold-R-Normal-*-140-* \
3317 -foreground brown -relief raised -borderwidth 1
3318 .data.record tag configure marc-small-head -foreground brown
3319 .data.record tag configure marc-pref \
3320 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3322 .data.record tag configure marc-text \
3323 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3325 .data.record tag configure marc-it \
3326 -font -Adobe-Times-Medium-I-Normal-*-140-* \
3329 button .bot.logo -bitmap @${libdir}/bitmaps/book1 -command cancel-operation
3331 .bot.logo configure -takefocus 0
3334 pack .bot.a -side left -fill x
3335 pack .bot.logo -side right -padx 2 -pady 2 -ipadx 1
3337 message .bot.a.target -text "" -aspect 1000 -border 1
3339 label .bot.a.status -text "Not connected" -width 15 -relief \
3340 sunken -anchor w -border 1
3341 label .bot.a.set -text "" -width 5 -relief \
3342 sunken -anchor w -border 1
3343 label .bot.a.message -text "" -width 15 -relief \
3344 sunken -anchor w -border 1
3346 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
3347 pack .bot.a.status .bot.a.set .bot.a.message \
3348 -side left -padx 2 -pady 2 -ipadx 1 -ipady 1
3350 if {[catch {ir z39}]} {
3351 set e [info sharedlibextension]
3352 puts -nonewline "Loading irtcl$e ..."
3359 if {$hostid != "Default"} {
3360 catch {open-target $hostid $hostbase}