1 # IR toolkit for tcl/tk
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
7 # Revision 1.78 1995-10-18 15:45:36 quinn
8 # *** empty log message ***
10 # Revision 1.77 1995/10/18 15:37:46 adam
13 # Revision 1.76 1995/10/18 15:15:20 adam
16 # Revision 1.75 1995/10/17 14:18:05 adam
17 # Minor changes in presentation formats.
19 # Revision 1.74 1995/10/17 12:18:57 adam
20 # Bug fix: when target connection closed, the connection was not
21 # properly reestablished.
23 # Revision 1.73 1995/10/17 10:58:06 adam
24 # More work on presentation formats.
26 # Revision 1.72 1995/10/16 17:00:52 adam
27 # New setting: elementSetNames.
28 # Various client improvements. Medium presentation format looks better.
30 # Revision 1.71 1995/10/13 15:35:27 adam
31 # Relational operators may be used in search entries - changes
32 # in proc index-query.
34 # Revision 1.70 1995/10/12 14:46:52 adam
35 # Better record popup windows. Next/prev buttons in popup record windows.
36 # The record position in the raw format is much more visible.
38 # Revision 1.69 1995/09/21 13:42:54 adam
41 # Revision 1.68 1995/09/21 13:11:49 adam
42 # Support of dynamic loading.
43 # Test script uses load command if necessary.
45 # Revision 1.67 1995/09/20 14:35:19 adam
48 # Revision 1.66 1995/08/29 15:30:13 adam
49 # Work on GRS records.
51 # Revision 1.65 1995/08/24 15:39:09 adam
54 # Revision 1.64 1995/08/24 15:33:02 adam
57 # Revision 1.63 1995/08/04 13:20:48 adam
58 # Buttons at the bottom are slightly smaller.
60 # Revision 1.62 1995/08/04 11:32:37 adam
61 # More work on output queue. Memory related routines moved
64 # Revision 1.61 1995/07/20 08:09:39 adam
65 # client.tcl: Targets removed from hotTargets list when targets
66 # are removed/modified.
67 # ir-tcl.c: More work on triggerResourceControl.
69 # Revision 1.60 1995/06/30 16:30:19 adam
72 # Revision 1.59 1995/06/29 14:06:25 adam
73 # Another bug in install fixed. Configure searches for more versions of yaz.
75 # Revision 1.58 1995/06/29 12:34:06 adam
76 # IrTcl now works with both tk4.0b4/tcl7.4b4 and tk3.6/tcl7.3
78 # Revision 1.57 1995/06/29 09:20:30 adam
79 # Target entries in cascade menus are sorted.
81 # Revision 1.56 1995/06/27 19:03:48 adam
82 # Bug fix in do_present in ir-tcl.c: p->set_child member weren't set.
83 # nextResultSetPosition used instead of setOffset.
85 # Revision 1.55 1995/06/27 17:10:37 adam
86 # Bug fix: install procedure didn't work on some systems.
87 # Error turned up when clientrc.tcl was't present.
89 # Revision 1.54 1995/06/27 14:41:03 adam
90 # Bug fix in search-response. Didn't always observe non-surrogate diagnostics.
92 # Revision 1.53 1995/06/26 12:40:09 adam
93 # Client defines its own tkerror.
94 # User may specify 'no preferredRecordSyntax'.
96 # Revision 1.52 1995/06/22 13:14:59 adam
97 # Feature: SUTRS. Setting getSutrs implemented.
98 # Work on display formats.
99 # Preferred record syntax can be set by the user.
101 # Revision 1.51 1995/06/21 11:11:00 adam
102 # Bug fix: libdir undefined in about-origin.
104 # Revision 1.50 1995/06/21 11:04:48 adam
105 # Uses GNU autoconf 2.3.
106 # Install procedure implemented.
107 # boook bitmaps moved to sub directory bitmaps.
109 # Revision 1.49 1995/06/20 14:16:42 adam
110 # More work on cancel mechanism.
112 # Revision 1.48 1995/06/20 08:07:23 adam
113 # New setting: failInfo.
114 # Working on better cancel mechanism.
116 # Revision 1.47 1995/06/19 14:05:29 adam
117 # Bug fix: asked for SUTRS.
119 # Revision 1.46 1995/06/19 13:06:06 adam
120 # New define: IR_TCL_VERSION.
122 # Revision 1.45 1995/06/19 08:08:44 adam
123 # client.tcl: hotTargets now contain both database and target name.
124 # ir-tcl.c: setting protocol edited. Errors in callbacks are logged
125 # by logf(LOG_WARN, ...) calls.
127 # Revision 1.44 1995/06/16 14:55:18 adam
128 # Book logo mirrored.
130 # Revision 1.43 1995/06/16 14:41:05 adam
131 # Scan line entries can be copied to a search entry.
133 # Revision 1.42 1995/06/16 12:28:13 adam
134 # Implemented preferredRecordSyntax.
135 # Minor changes in diagnostic handling.
136 # Record list deleted when connection closes.
138 # Revision 1.41 1995/06/14 15:07:59 adam
139 # Bug fix in cascade-target-list. Uses yaz-version.h.
141 # Revision 1.40 1995/06/14 13:37:17 adam
142 # Setting recordType implemented.
143 # Setting implementationVersion implemented.
144 # Settings implementationId / implementationName edited.
146 # Revision 1.39 1995/06/14 12:16:22 adam
147 # hotTargets, textWrap and displayFormat saved in clientg.tcl.
149 # Revision 1.38 1995/06/14 07:22:45 adam
150 # Target definitions can be deleted.
151 # Listbox used in the query definition dialog.
153 # Revision 1.37 1995/06/13 14:37:59 adam
154 # Work on query setup.
155 # Better about origin/target.
156 # Better presentation formats.
158 # Revision 1.36 1995/06/13 07:42:14 adam
159 # Bindings removed from text widgets.
161 # Revision 1.35 1995/06/12 15:17:31 adam
162 # Text widget used in main window (instead of listbox) to support
163 # better presentation formats.
165 # Revision 1.34 1995/06/12 07:59:07 adam
166 # More work on geometry handling.
168 # Revision 1.33 1995/06/09 11:17:35 adam
169 # Start work on geometry management.
171 # Revision 1.32 1995/06/07 09:16:37 adam
172 # New presentation format.
174 # Revision 1.31 1995/06/06 16:31:09 adam
175 # Bug fix: target names couldn't contain blanks.
178 # Revision 1.30 1995/06/06 11:35:41 adam
179 # Work on scan. Display of old sets.
181 # Revision 1.29 1995/06/05 14:11:18 adam
182 # Bug fix in present-more.
184 # Revision 1.28 1995/06/02 14:52:13 adam
185 # Minor changes really.
187 # Revision 1.27 1995/06/02 14:29:42 adam
188 # Work on scan interface - up/down buttons.
190 # Revision 1.26 1995/06/01 16:36:46 adam
191 # About buttons. Minor bug fixes.
193 # Revision 1.25 1995/05/31 13:09:57 adam
194 # Client searches/presents may be interrupted.
195 # New moving book-logo.
197 # Revision 1.24 1995/05/31 08:36:24 adam
198 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
199 # New method: referenceId. More work on scan.
201 # Revision 1.23 1995/05/29 10:33:41 adam
202 # README and rename of startup script.
204 # Revision 1.22 1995/05/26 11:44:09 adam
205 # Bugs fixed. More work on MARC utilities and queries. Test
206 # client is up-to-date again.
208 # Revision 1.21 1995/05/11 15:34:46 adam
209 # Scan request changed a bit. This version works with RLG.
211 # Revision 1.20 1995/04/21 16:31:57 adam
212 # New radiobutton: protocol (z39v2/SR).
214 # Revision 1.19 1995/04/18 16:11:50 adam
215 # First version of graphical Scan. Some work on query-by-form.
217 # Revision 1.18 1995/04/10 10:50:22 adam
218 # Result-set name defaults to suffix of ir-set name.
219 # Started working on scan. Not finished at this point.
221 # Revision 1.17 1995/03/31 09:34:57 adam
222 # Search-button disabled when there is no connection.
224 # Revision 1.16 1995/03/31 08:56:36 adam
225 # New button "Search".
227 # Revision 1.15 1995/03/28 12:45:22 adam
228 # New ir method failback: called on disconnect/protocol error.
229 # New ir set/get method: protocol: SR / Z3950.
230 # Simple popup and disconnect when failback is invoked.
232 # Revision 1.14 1995/03/22 16:07:55 adam
235 # Revision 1.13 1995/03/21 17:27:26 adam
236 # Short-hand keys in setup.
238 # Revision 1.12 1995/03/21 13:41:03 adam
239 # Comstack cs_create not used too often. Non-blocking connect.
241 # Revision 1.11 1995/03/21 10:39:06 adam
242 # Diagnostic error message displayed with tkerror.
244 # Revision 1.10 1995/03/20 15:24:06 adam
245 # Diagnostic records saved on searchResponse.
247 # Revision 1.9 1995/03/17 18:26:16 adam
248 # Non-blocking i/o used now. Database names popup as cascade items.
250 # Revision 1.8 1995/03/17 15:45:00 adam
251 # Improved target/database setup.
253 # Revision 1.7 1995/03/16 17:54:03 adam
254 # Minor changes really.
256 # Revision 1.6 1995/03/15 19:10:20 adam
257 # Database setup in protocol-setup (rather target setup).
259 # Revision 1.5 1995/03/15 13:59:23 adam
262 # Revision 1.4 1995/03/14 17:32:29 adam
263 # Presentation of full Marc record in popup window.
265 # Revision 1.3 1995/03/12 19:31:52 adam
266 # Pattern matching implemented when retrieving MARC records. More
267 # diagnostic functions.
269 # Revision 1.2 1995/03/10 18:00:15 adam
270 # Actual presentation in line-by-line format. RPN query support.
272 # Revision 1.1 1995/03/09 16:15:07 adam
273 # First presentRequest attempts. Hot-target list.
277 if {$tk_version == "3.6"} {
288 proc configure-enable-e {w n} {
290 $w entryconfigure $n -state normal
292 proc configure-disable-e {w n} {
294 $w entryconfigure $n -state disabled
296 set noFocus [list -takefocus 0]
298 proc configure-enable-e {w n} {
301 proc configure-disable-e {w n} {
308 if {[tk colormodel .] == "color"} {
318 if {[file readable bitmaps/book2]} {
321 if {! [file readable ${libdir}/bitmaps/book2]} {
322 puts "Cannot locate system files in ${libdir}. You must either run this"
323 puts "program from the source directory root of ir-tcl or you must assure"
324 puts "that it is installed - normally in /usr/local/lib/irtcl"
332 set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} Z39 1}
334 set settingsChanged 0
342 set recordSyntax None
343 set elementSetNames None
346 set queryTypes {Simple}
347 set queryButtons { { {I 0} {I 1} {I 2} } }
348 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
349 {Subject {1=21}} {Any {1=1016}} } }
358 if {[winfo exists $w]} {
367 label $w.top.b -bitmap error
368 message $w.top.t -aspect 300 -text "Error: $err" \
369 -font -Adobe-Helvetica-Bold-R-Normal-*-180-*
370 pack $w.top.b $w.top.t -side left -padx 10 -pady 10
372 bottom-buttons $w [list {Close} [list destroy $w]] 1
375 proc read-formats {} {
376 global displayFormats
378 if {[catch {set formats [glob -nocomplain ${libdir}/formats/*.tcl]}]} {
379 set formats ./formats/raw.tcl
382 if {[file readable $f]} {
384 set l [string length $f]
385 set f [string range $f [string length "${libdir}/formats/"] \
387 lappend displayFormats $f
396 .data.record configure -wrap $m
403 proc set-display-format {f} {
413 .bot.a.status configure -text "Reformatting"
416 add-title-lines -1 10000 1
419 proc initBindings {} {
422 bind $w <Double-1> {}
423 bind $w <Triple-1> {}
424 bind $w <B1-Motion> {}
426 bind $w <Shift-B1-Motion> {}
428 bind $w <B2-Motion> {}
429 bind $w <Any-KeyPress> {}
431 bind $w <BackSpace> {}
433 bind $w <Control-h> {}
434 bind $w <Control-d> {}
435 bind $w <Control-v> {}
438 bind $w <B1-Motion> {}
439 bind $w <Shift-B1-Motion> {}
444 proc post-menu {wbutton wmenu} {
447 $wmenu post [winfo rootx $wbutton] \
448 [expr [winfo rooty $wbutton]+[winfo height $wbutton]]
453 global windowGeometry
454 set windowGeometry($w) [wm geometry $w]
457 global windowGeometry
460 if {[info exists windowGeometry($w)]} {
461 set g $windowGeometry($w)
466 bind $w <Destroy> [list destroyGW $w]
469 if {[file readable "clientrc.tcl"]} {
470 source "clientrc.tcl"
472 if {[file readable "${libdir}/clientrc.tcl"]} {
473 source "${libdir}/clientrc.tcl"
477 if {[file readable "~/.clientrc.tcl"]} {
478 source "~/.clientrc.tcl"
481 set queryButtonsFind [lindex $queryButtons 0]
482 set queryInfoFind [lindex $queryInfo 0]
484 proc top-down-window {w} {
485 frame $w.top -relief raised -border 1
486 frame $w.bot -relief raised -border 1
488 pack $w.top -side top -fill both -expand yes
489 pack $w.bot -fill both
492 proc top-down-ok-cancel {w ok-action g} {
493 frame $w.bot.left -relief sunken -border 1
494 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 1 -pady 1
495 button $w.bot.left.ok -width 4 -text {Ok} \
496 -command ${ok-action}
497 pack $w.bot.left.ok -expand yes -ipadx 1 -ipady 1 -padx 2 -pady 2
498 button $w.bot.cancel -width 5 -text {Cancel} \
499 -command [list destroy $w]
500 pack $w.bot.cancel -side left -expand yes
508 proc bottom-buttons {w buttonList g} {
510 set l [llength $buttonList]
512 frame $w.bot.$i -relief sunken -border 1
513 pack $w.bot.$i -side left -expand yes -padx 2 -pady 2
514 button $w.bot.$i.ok -text [lindex $buttonList $i] \
515 -command [lindex $buttonList [expr $i+1]]
516 pack $w.bot.$i.ok -expand yes -padx 2 -pady 2 -side left
520 button $w.bot.$i -text [lindex $buttonList $i] \
521 -command [lindex $buttonList [expr $i+1]]
522 pack $w.bot.$i -expand yes -padx 2 -pady 2 -side left
532 proc cancel-operation {} {
540 show-status Cancel 0 1
544 proc show-target {target base} {
548 .bot.a.target configure -text ""
552 .bot.a.target configure -text "$target"
554 .bot.a.target configure -text "$target - $base"
558 proc show-logo {v1} {
567 .bot.logo configure -bitmap @${libdir}/bitmaps/book${v1}
568 after 140 [list show-logo $v1]
572 .bot.logo configure -bitmap @${libdir}/bitmaps/book1
581 proc show-status {status b sb} {
588 .bot.a.status configure -text "$status"
590 if {$busy == 0} {set busy 1}
598 .top.service configure -state normal
599 .mid.search configure -state normal
601 .mid.scan configure -state normal
604 configure-disable-e .top.service.m 1
605 } elseif {[z39.$setNo nextResultSetPosition] > 0 &&
606 [z39.$setNo nextResultSetPosition] <= [z39.$setNo resultCount]} {
607 configure-enable-e .top.service.m 1
608 .mid.present configure -state normal
610 configure-disable-e .top.service.m 1
611 .mid.present configure -state disabled
613 if {[winfo exists .scan-window]} {
614 .scan-window.bot.2 configure -state normal
615 .scan-window.bot.4 configure -state normal
618 .top.service configure -state disabled
619 .mid.search configure -state disabled
620 .mid.scan configure -state disabled
621 .mid.present configure -state disabled
623 if {[winfo exists .scan-window]} {
624 .scan-window.bot.2 configure -state disabled
625 .scan-window.bot.4 configure -state disabled
630 proc show-message {msg} {
631 .bot.a.message configure -text "$msg"
634 proc insertWithTags {w text args} {
635 set start [$w index insert]
636 $w insert insert $text
637 foreach tag [$w tag names $start] {
638 $w tag remove $tag $start insert
641 $w tag add $i $start insert
645 proc popup-license {} {
650 wm title $w "License"
656 text $w.top.t -width 80 -height 10 -wrap word \
657 -yscrollcommand [list $w.top.s set]
658 scrollbar $w.top.s -command [list $w.top.t yview]
660 pack $w.top.s -side right -fill y
661 pack $w.top.t -expand yes -fill both
663 if {[file readable "${libdir}/LICENSE"]} {
664 set f [open "${libdir}/LICENSE" r]
665 while {[gets $f buf] != -1} {
666 $w.top.t insert end $buf
667 $w.top.t insert end "\n"
671 bottom-buttons $w [list {Close} [list destroy $w]] 1
674 proc about-target {} {
675 set w .about-target-w
680 wm title $w "About target"
684 frame $w.top.a -relief ridge -border 2
685 frame $w.top.p -relief ridge -border 2
687 pack $w.top.a $w.top.p -side top -fill x
689 label $w.top.a.about -text "About"
690 label $w.top.a.irtcl -text $hostid \
691 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
692 pack $w.top.a.about $w.top.a.irtcl -side top
694 set i [z39 targetImplementationName]
695 label $w.top.p.in -text "Implementation name: $i"
696 set i [z39 targetImplementationId]
697 label $w.top.p.ii -text "Implementation id: $i"
698 set i [z39 targetImplementationVersion]
699 label $w.top.p.iv -text "Implementation version: $i"
701 label $w.top.p.op -text "Protocol options: $i"
703 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
705 bottom-buttons $w [list {Close} [list destroy $w]] 1
708 proc about-origin-logo {n} {
710 set w .about-origin-w
711 if {![winfo exists $w]} {
718 $w.top.a.logo configure -bitmap @${libdir}/bitmaps/book$n
719 after 140 [list about-origin-logo $n]
722 proc about-origin {} {
723 set w .about-origin-w
727 if {[winfo exists $w]} {
732 wm title $w "About IrTcl"
736 frame $w.top.a -relief ridge -border 2
737 frame $w.top.p -relief ridge -border 2
739 pack $w.top.a $w.top.p -side top -fill x
741 label $w.top.a.irtcl -text "IrTcl" \
742 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
743 label $w.top.a.logo -bitmap @${libdir}/bitmaps/book1
744 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
747 catch {set i [z39 implementationName]}
748 label $w.top.p.in -text "Implementation name: $i"
749 catch {set i [z39 implementationId]}
750 label $w.top.p.ii -text "Implementation id: $i"
751 catch {set i [z39 implementationVersion]}
752 label $w.top.p.iv -text "Implementation version: $i"
754 label $w.top.p.tk -text "Tk version: $i"
756 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.tk -side top -anchor nw
759 bottom-buttons $w [list {Close} [list destroy $w] \
760 {License} [list popup-license]] 0
763 proc popup-marc {sno no b df} {
764 global displayFormats
767 if {[z39.$sno type $no] != "DB"} {
772 while {[winfo exists .full-marc$b]} {
778 if {![winfo exists $w]} {
783 frame $w.top -relief raised -border 1
784 frame $w.bot -relief raised -border 1
786 pack $w.top -side top -fill both -expand yes
787 pack $w.bot -fill both
789 text $w.top.record -width 60 -height 5 -wrap word \
790 -yscrollcommand [list $w.top.s set]
791 scrollbar $w.top.s -command [list $w.top.record yview]
795 $w.top.record tag configure marc-tag -foreground blue
796 $w.top.record tag configure marc-id -foreground red
798 $w.top.record tag configure marc-tag -foreground black
799 $w.top.record tag configure marc-id -foreground black
801 $w.top.record tag configure marc-data -foreground black
802 $w.top.record tag configure marc-head \
803 -font -Adobe-Times-Medium-R-Normal-*-180-* \
804 -background black -foreground white
806 $w.top.record tag configure marc-pref \
807 -font -Adobe-Times-Medium-R-Normal-*-180-* \
809 $w.top.record tag configure marc-text \
810 -font -Adobe-Times-Medium-R-Normal-*-180-* \
812 $w.top.record tag configure marc-it \
813 -font -Adobe-Times-Medium-I-Normal-*-180-* \
816 pack $w.top.s -side right -fill y
817 pack $w.top.record -expand yes -fill both
819 bottom-buttons $w [list \
820 {Close} [list destroy $w] \
824 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m \
826 menu $w.bot.formats.m
827 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 \
828 -padx 3 -pady 3 -side left
830 $w.bot.formats.m delete 0 last
833 foreach f $displayFormats {
834 $w.bot.formats.m add radiobutton -label $f \
835 -variable popupMarcdf -value $i \
836 -command [list popup-marc $sno $no $b 0]
839 $w.top.record delete 0.0 end
840 set recordType [z39.$sno recordType $no]
841 wm title $w "$recordType record #$no"
843 $w.bot.2 configure -command \
844 [list popup-marc $sno [expr $no-1] $b $df]
845 $w.bot.4 configure -command \
846 [list popup-marc $sno [expr $no+1] $b $df]
848 $w.bot.2 configure -state disabled
850 $w.bot.2 configure -state normal
852 if {[z39.$sno type [expr $no+1]] != "DB"} {
853 $w.bot.4 configure -state disabled
855 $w.bot.4 configure -state normal
857 $w.bot.6 configure -command [list popup-marc $sno $no -1 0]
858 set ffunc [lindex $displayFormats $df]
859 set ffunc "display-$ffunc"
861 $ffunc $sno $no $w.top.record 0
864 proc update-target-hotlist {target base} {
867 set olen [llength $hotTargets]
869 foreach e $hotTargets {
870 if {$target == [lindex $e 0] && $base == [lindex $e 1]} {
871 set hotTargets [lreplace $hotTargets $i $i]
876 set hotTargets [linsert $hotTargets 0 [list $target $base]]
877 set-target-hotlist $olen
880 proc delete-target-hotlist {target} {
883 set olen [llength $hotTargets]
885 foreach e $hotTargets {
886 if {$target == [lindex $e 0]} {
887 set hotTargets [lreplace $hotTargets $i $i]
891 set-target-hotlist $olen
894 proc set-target-hotlist {olen} {
899 .top.target.m delete 7 [expr 7+$olen]
901 .top.target.m delete 6 [expr 6+$olen]
905 foreach e $hotTargets {
906 set target [lindex $e 0]
907 set base [lindex $e 1]
909 .top.target.m add command -label "$i $target" -command \
910 [list reopen-target $target {}]
912 .top.target.m add command -label "$i $target - $base" -command \
913 [list reopen-target $target $base]
922 proc reopen-target {target base} {
924 open-target $target $base
925 update-target-hotlist $target $base
928 proc define-target-action {} {
931 set target [.target-define.top.target.entry get]
935 foreach n [array names profile] {
941 set seq [lindex $profile(Default) 12]
943 set profile($target) $profile(Default)
944 set profile(Default) [lreplace $profile(Default) 12 12 [incr seq]]
946 protocol-setup $target
947 destroy .target-define
950 proc fail-response {target} {
951 set c [lindex [z39 failInfo] 0]
952 set m [lindex [z39 failInfo] 1]
957 proc connect-response {target base} {
958 dputs "connect-response"
959 show-target $target $base
963 proc open-target {target base} {
968 z39 comstack [lindex $profile($target) 6]
969 z39 protocol [lindex $profile($target) 11]
970 z39 idAuthentication [lindex $profile($target) 3]
971 z39 maximumRecordSize [lindex $profile($target) 4]
972 z39 preferredMessageSize [lindex $profile($target) 5]
973 dputs "maximumRecordSize="
974 dputs [z39 maximumRecordSize]
975 dputs "preferredMessageSize="
976 dputs [z39 preferredMessageSize]
977 show-status Connecting 1 0
979 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
981 z39 databaseNames $base
983 z39 failback [list fail-response $target]
984 z39 callback [list connect-response $target $base]
987 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
990 tkerror $errorMessage
991 show-status "Not connected" 0 {}
995 configure-disable-e .top.target.m 0
996 configure-enable-e .top.target.m 1
997 configure-enable-e .top.target.m 2
1000 proc close-target {} {
1009 .bot.a.set configure -text ""
1013 show-status {Not connected} 0 0
1016 configure-disable-e .top.target.m 1
1017 configure-disable-e .top.target.m 2
1019 .top.rset.m delete 2 last
1021 .top.rset.m delete 1 last
1023 .top.rset.m add separator
1024 configure-enable-e .top.target.m 0
1027 proc load-set-action {} {
1031 ir-set z39.$setNoLast z39
1033 set fname [.load-set.top.filename.entry get]
1036 show-status Loading 1 {}
1038 z39.$setNoLast loadFile $fname
1040 set no [z39.$setNoLast numberOfRecordsReturned]
1041 add-title-lines $setNoLast $no 1
1043 set l [format "%-4d %7d" $setNoLast $no]
1044 .top.rset.m add command -label $l \
1045 -command [list add-title-lines $setNoLast 10000 1]
1046 show-status Ready 0 {}
1052 set oldFocus [focus]
1056 frame $w.top.filename
1057 pack $w.top.filename -side top -anchor e -pady 2
1059 entry-fields $w.top {filename} \
1061 {load-set-action} {destroy .load-set}
1063 top-down-ok-cancel $w {load-set-action} 1
1067 proc init-request {} {
1074 z39 callback {init-response}
1075 show-status Initializing 1 {}
1076 set err [catch {z39 init} errorMessage]
1078 tkerror $errorMessage
1079 show-status Ready 0 {}
1083 proc init-response {} {
1087 dputs {init-reponse}
1092 if {![z39 initResult]} {
1093 show-status Ready 0 1
1094 set u [z39 userInformationField]
1096 tkerror "Connection rejected by target: $u"
1098 if {[lsearch [z39 options] scan] >= 0} {
1103 show-status Ready 0 1
1107 proc search-request {bflag} {
1116 global elementSetNames
1120 if {[z39 connect] == ""} {
1123 dputs "search-request"
1125 if {!$bflag && $busy} {
1126 dputs "busy: search-request ignored"
1131 show-status Searching 1 0
1132 set delayRequest {search-request 1}
1137 set query [index-query]
1142 set setNo $setNoLast
1143 ir-set z39.$setNo z39
1145 if {[lindex $profile($target) 10] == 1} {
1146 z39.$setNo setName $setNo
1147 dputs "setName=${setNo}"
1149 z39.$setNo setName Default
1150 dputs "setName=Default"
1152 if {[lindex $profile($target) 8] == 1} {
1153 z39.$setNo queryType rpn
1155 if {[lindex $profile($target) 9] == 1} {
1156 z39.$setNo queryType ccl
1160 if {$recordSyntax == "None" } {
1161 z39.$setNo preferredRecordSyntax {}
1163 z39.$setNo preferredRecordSyntax $recordSyntax
1165 if {$elementSetNames == "None" } {
1166 z39.$setNo elementSetNames {}
1168 z39.$setNo elementSetNames $elementSetNames
1170 z39 callback {search-response}
1171 z39.$setNo search $query
1172 show-status Searching 1 0
1175 proc scan-copy {y entry} {
1177 set no [$w.top.list nearest $y]
1179 .lines.$entry.e delete 0 end
1180 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
1183 proc scan-request {} {
1190 global curIndexEntry
1191 global queryButtonsFind
1192 global queryInfoFind
1196 dputs "scan-request"
1199 show-status Scanning 1 0
1200 set delayRequest scan-request
1209 set b [lindex $queryButtonsFind $curIndexEntry]
1211 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
1212 set attr "@attr $a $attr"
1214 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
1215 ir-scan z39.scan z39
1217 if {![winfo exists $w]} {
1224 entry $w.top.entry -relief sunken
1225 pack $w.top.entry -fill x -padx 4 -pady 2
1226 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
1227 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
1229 scrollbar $w.top.scroll -orient vertical -border 1
1230 pack $w.top.list -side left -fill both -expand yes
1231 pack $w.top.scroll -side right -fill y
1232 $w.top.scroll config -command [list $w.top.list yview]
1234 bottom-buttons $w [list {Close} [list destroy $w] \
1235 {Up} [list scan-up $attr] \
1236 {Down} [list scan-down $attr]] 0
1237 bind $w.top.list <Up> [list scan-up $attr]
1238 bind $w.top.list <Down> [list scan-down $attr]
1241 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
1242 wm title $w "Scan $title"
1244 z39 callback [list scan-response $attr 0 35]
1245 z39.scan numberOfTermsRequested 5
1246 z39.scan preferredPositionInResponse 1
1247 z39.scan scan "${attr} 0"
1249 show-status Scanning 1 0
1252 proc scan-term-h {attr} {
1260 set nScanTerm [$w.top.entry get]
1261 if {$nScanTerm == $scanTerm} {
1264 set scanTerm $nScanTerm
1265 z39 callback [list scan-response $attr 0 35]
1266 z39.scan numberOfTermsRequested 5
1267 z39.scan preferredPositionInResponse 1
1268 dputs "${attr} \{${scanTerm}\}"
1269 if {$scanTerm == ""} {
1270 z39.scan scan "${attr} 0"
1272 z39.scan scan "${attr} \{${scanTerm}\}"
1274 show-status Scanning 1 0
1277 proc scan-response {attr start toget} {
1284 dputs "In scan-response"
1285 set m [z39.scan numberOfEntriesReturned]
1291 if {![winfo exists .scan-window]} {
1294 dputs "Handling cancel"
1295 if {$delayRequest != ""} {
1300 show-status Ready 0 1
1303 set nScanTerm [$w.top.entry get]
1304 if {$nScanTerm != $scanTerm} {
1305 z39 callback [list scan-response $attr 0 35]
1306 z39.scan numberOfTermsRequested 5
1307 z39.scan preferredPositionInResponse 1
1308 set scanTerm $nScanTerm
1309 dputs "${attr} \{${scanTerm}\}"
1310 if {$scanTerm == ""} {
1311 z39.scan scan "${attr} 0"
1313 z39.scan scan "${attr} \{${scanTerm}\}"
1315 show-status Scanning 1 0
1318 set status [z39.scan scanStatus]
1321 show-status Ready 0 1
1326 for {set i 0} {$i < $m} {incr i} {
1327 set term [lindex [z39.scan scanLine $i] 1]
1328 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1329 $w.top.list insert $i "$nostr $term"
1332 $w.top.list yview $scanView
1334 $w.top.list delete $start end
1335 for {set i 0} {$i < $m} {incr i} {
1336 set term [lindex [z39.scan scanLine $i] 1]
1337 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1338 $w.top.list insert end "$nostr $term"
1342 dputs "Handling cancel"
1344 if {$delayRequest != ""} {
1350 if {$toget > 0 && $m > 1 && $m < $toget} {
1351 set ntoget [expr $toget - $m + 1]
1352 dputs ntoget=$ntoget
1353 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1355 dputs "down continue: $q"
1357 z39.scan numberOfTermsRequested 10
1359 z39.scan numberOfTermsRequested $ntoget
1361 z39.scan preferredPositionInResponse 1
1362 dputs "${attr} \{$q\}"
1363 z39.scan scan "${attr} \{$q\}"
1366 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1367 set ntoget [expr - $toget - $m]
1368 dputs ntoget=$ntoget
1369 z39 callback [list scan-response $attr 0 -$ntoget]
1370 set q [string range [$w.top.list get 0] 8 end]
1371 dputs "up continue: $q"
1373 z39.scan numberOfTermsRequested 10
1374 z39.scan preferredPositionInResponse 11
1376 z39.scan numberOfTermsRequested $ntoget
1377 z39.scan preferredPositionInResponse [incr ntoget]
1379 dputs "${attr} \{$q\}"
1380 z39.scan scan "${attr} \{$q\}"
1383 show-status Ready 0 1
1386 proc scan-down {attr} {
1394 show-status {Scanning down} 1 0
1395 set delayRequest [list scan-down $attr]
1401 set scanView [expr $scanView + 5]
1402 set s [$w.top.list size]
1403 if {$scanView > $s} {
1404 z39 callback [list scan-response $attr [expr $s - 1] 25]
1405 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1407 z39.scan numberOfTermsRequested 10
1408 z39.scan preferredPositionInResponse 1
1409 show-status Scanning 1 0
1410 dputs "${attr} \{$q\}"
1411 z39.scan scan "${attr} \{$q\}"
1414 $w.top.list yview $scanView
1417 proc scan-up {attr} {
1425 show-status Scanning 1 0
1426 set delayRequest [list scan-up $attr]
1432 set scanView [expr $scanView - 5]
1433 if {$scanView < 0} {
1434 z39 callback [list scan-response $attr 0 -25]
1435 set q [string range [$w.top.list get 0] 8 end]
1437 z39.scan numberOfTermsRequested 10
1438 z39.scan preferredPositionInResponse 11
1439 show-status Scanning 1 0
1440 z39.scan scan "${attr} \{$q\}"
1443 $w.top.list yview $scanView
1446 proc search-response {} {
1454 dputs "In search-response"
1456 dputs "Handling cancel"
1458 if {$delayRequest != ""} {
1466 set setMax [z39.$setNo resultCount]
1467 show-status Ready 0 1
1468 set status [z39.$setNo responseStatus]
1469 if {[lindex $status 0] == "NSD"} {
1470 z39.$setNo nextResultSetPosition 0
1471 set code [lindex $status 1]
1472 set msg [lindex $status 2]
1473 set addinfo [lindex $status 3]
1474 tkerror "NSD$code: $msg: $addinfo"
1477 show-message "${setMax} hits"
1482 show-status Ready 0 1
1483 set l [format "%-4d %7d" $setNo $setMax]
1484 .top.rset.m add command -label $l \
1485 -command [list add-title-lines $setNo 10000 1]
1489 set no [z39.$setNo numberOfRecordsReturned]
1490 dputs "Returned $no records, setOffset $setOffset"
1491 add-title-lines $setNo $no $setOffset
1492 set setOffset [expr $setOffset + $no]
1493 z39 callback {present-response}
1494 z39.$setNo present $setOffset 1
1495 show-status Retrieving 1 0
1498 proc present-more {number} {
1506 dputs "present-more"
1508 show-status Retrieving 1 0
1509 set delayRequest "present-more $number"
1515 dputs "setNo=$setNo"
1518 set setOffset [z39.$setNo nextResultSetPosition]
1519 dputs "setOffest=${setOffset}"
1520 dputs "setNo=${setNo}"
1521 set max [z39.$setNo resultCount]
1522 if {$max < $setOffset} {
1524 dputs "setOffset=$setOffset"
1525 show-status Ready 0 1
1528 if {$number == ""} {
1532 if {$setMax > $max} {
1536 z39 callback {present-response}
1538 set toGet [expr $setMax - $setOffset + 1]
1545 z39.$setNo present $setOffset $toGet
1546 show-status Retrieving 1 0
1549 proc init-title-lines {} {
1550 .data.record delete 0.0 end
1553 proc add-title-lines {setno no offset} {
1554 global displayFormats
1555 global displayFormat
1565 .bot.a.set configure -text $setno
1566 .data.record delete 0.0 end
1568 set ffunc [lindex $displayFormats $displayFormat]
1569 dputs "ffunc=$ffunc"
1570 set ffunc "display-$ffunc"
1571 for {set i 0} {$i < $no} {incr i} {
1572 set o [expr $i + $offset]
1573 set type [z39.$setno type $o]
1577 .data.record tag bind r$o <Any-Enter> {}
1578 .data.record tag bind r$o <Any-Leave> {}
1579 set insert0 [.data.record index insert]
1580 $ffunc $setno $o .data.record 1
1581 .data.record tag add r$o $insert0 insert
1582 .data.record tag bind r$o <1> \
1583 [list popup-marc $setno $o 0 0]
1587 show-status Ready 0 1
1591 proc present-response {} {
1598 dputs "In present-response"
1599 set no [z39.$setNo numberOfRecordsReturned]
1600 dputs "Returned $no records, setOffset $setOffset"
1601 add-title-lines $setNo $no $setOffset
1602 set setOffset [expr $setOffset + $no]
1604 dputs "Handling cancel"
1606 if {$delayRequest != ""} {
1611 set status [z39.$setNo responseStatus]
1612 if {[lindex $status 0] == "NSD"} {
1613 show-status Ready 0 1
1614 set code [lindex $status 1]
1615 set msg [lindex $status 2]
1616 set addinfo [lindex $status 3]
1617 tkerror "NSD$code: $msg: $addinfo"
1620 if {$no > 0 && $setOffset <= $setMax} {
1621 dputs "present-request from ${setOffset}"
1622 set toGet [expr $setMax - $setOffset + 1]
1626 z39.$setNo present $setOffset $toGet
1628 show-status Ready 0 1
1632 proc left-cursor {w} {
1633 set i [$w index insert]
1641 proc right-cursor {w} {
1642 set i [$w index insert]
1648 proc bind-fields {list returnAction escapeAction} {
1649 set max [expr [llength $list]-1]
1650 for {set i 0} {$i < $max} {incr i} {
1651 bind [lindex $list $i] <Return> $returnAction
1652 bind [lindex $list $i] <Escape> $escapeAction
1654 bind [lindex $list $i] <Tab> \
1655 [list focus [lindex $list [expr $i+1]]]
1656 bind [lindex $list $i] <Left> \
1657 [list left-cursor [lindex $list $i]]
1658 bind [lindex $list $i] <Right> \
1659 [list right-cursor [lindex $list $i]]
1662 bind [lindex $list $i] <Return> $returnAction
1663 bind [lindex $list $i] <Escape> $escapeAction
1665 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1666 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1667 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1669 focus [lindex $list 0]
1672 proc entry-fields {parent list tlist returnAction escapeAction} {
1675 foreach field $list {
1676 set label ${parent}.${field}.label
1677 set entry ${parent}.${field}.entry
1678 label $label -text [lindex $tlist $i] -anchor e
1679 entry $entry -width 32 -relief sunken
1680 pack $label -side left
1681 pack $entry -side right
1682 lappend alist $entry
1685 bind-fields $alist $returnAction $escapeAction
1688 proc define-target-dialog {} {
1689 set w .target-define
1695 pack $w.top.target \
1696 -side top -anchor e -pady 2
1697 entry-fields $w.top {target} \
1699 {define-target-action} {destroy .target-define}
1700 top-down-ok-cancel $w {define-target-action} 1
1703 proc protocol-setup-delete {target w} {
1705 global settingsChanged
1707 set a [alert "Are you sure you want to delete the target \
1708 definition $target ?"]
1711 unset profile($target)
1712 set settingsChanged 1
1714 delete-target-hotlist $target
1718 proc protocol-setup-action {target w} {
1721 global protocolRadioType
1722 global settingsChanged
1725 global ResultSetCheck
1728 set settingsChanged 1
1729 set len [$w.top.databases.list size]
1730 for {set i 0} {$i < $len} {incr i} {
1731 lappend b [$w.top.databases.list get $i]
1733 set wno [lindex $profile($target) 12]
1735 set profile($target) [list [$w.top.description.entry get] \
1736 [$w.top.host.entry get] \
1737 [$w.top.port.entry get] \
1738 [$w.top.idAuthentication.entry get] \
1739 [$w.top.maximumRecordSize.entry get] \
1740 [$w.top.preferredMessageSize.entry get] \
1746 $protocolRadioType \
1750 delete-target-hotlist $target
1751 dputs $profile($target)
1755 proc place-force {window parent} {
1756 set g [wm geometry $parent]
1758 set p1 [string first + $g]
1759 set p2 [string last + $g]
1761 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1762 set y [expr 60+[string range $g [expr $p2 +1] end]]
1763 wm geometry $window +${x}+${y}
1766 proc add-database-action {target w} {
1769 $w.top.databases.list insert end \
1770 [.database-select.top.database.entry get]
1771 destroy .database-select
1774 proc add-database {target wp} {
1777 set w .database-select
1779 set oldFocus [focus]
1785 frame $w.top.database
1787 pack $w.top.database -side top -anchor e -pady 2
1789 entry-fields $w.top {database} \
1790 {{Database to add:}} \
1791 [list add-database-action $target $wp] {destroy .database-select}
1793 top-down-ok-cancel $w [list add-database-action $target $wp] 1
1797 proc delete-database {target w} {
1801 foreach i [$w.top.databases.list curselection] {
1802 set b [$w.top.databases.list get $i]
1805 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1807 foreach i [lsort -decreasing \
1808 [$w.top.databases.list curselection]] {
1809 $w.top.databases.list delete $i
1814 proc protocol-setup {target} {
1817 global protocolRadioType
1820 global ResultSetCheck
1823 while {[winfo exists .setup-$b]} {
1830 wm title $w "Setup $target"
1834 if {$target == ""} {
1838 dputs $profile($target)
1840 frame $w.top.description
1843 frame $w.top.idAuthentication
1844 frame $w.top.maximumRecordSize
1845 frame $w.top.preferredMessageSize
1846 frame $w.top.cs-type -relief ridge -border 2
1847 frame $w.top.protocol -relief ridge -border 2
1848 frame $w.top.query -relief ridge -border 2
1849 frame $w.top.databases -relief ridge -border 2
1851 # Maximum/preferred/idAuth ...
1852 pack $w.top.description $w.top.host $w.top.port \
1853 $w.top.idAuthentication $w.top.maximumRecordSize \
1854 $w.top.preferredMessageSize -side top -anchor e -pady 2
1856 entry-fields $w.top {description host port idAuthentication \
1857 maximumRecordSize preferredMessageSize} \
1858 {{Description:} {Host:} {Port:} {Id Authentication:} \
1859 {Maximum Record Size:} {Preferred Message Size:}} \
1860 [list protocol-setup-action $target $w] [list destroy $w]
1862 foreach sub {description host port idAuthentication \
1863 maximumRecordSize preferredMessageSize} {
1865 bind $w.top.$sub.entry <Control-a> [list add-database $target $w]
1866 bind $w.top.$sub.entry <Control-d> [list delete-database $target $w]
1868 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1869 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1870 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1871 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1872 $w.top.maximumRecordSize.entry insert 0 [lindex $profile($target) 4]
1873 $w.top.preferredMessageSize.entry insert 0 [lindex $profile($target) 5]
1874 set csRadioType [lindex $profile($target) 6]
1875 set RPNCheck [lindex $profile($target) 8]
1876 set CCLCheck [lindex $profile($target) 9]
1877 set ResultSetCheck [lindex $profile($target) 10]
1878 set protocolRadioType [lindex $profile($target) 11]
1879 if {$protocolRadioType == ""} {
1880 set protocolRadioType Z39
1884 pack $w.top.databases -side left -pady 2 -padx 2 -expand yes -fill both
1886 label $w.top.databases.label -text "Databases"
1887 button $w.top.databases.add -text Add \
1888 -command [list add-database $target $w]
1889 button $w.top.databases.delete -text Delete \
1890 -command [list delete-database $target $w]
1892 listbox $w.top.databases.list -geometry 14x6 \
1893 -yscrollcommand "$w.top.databases.scroll set"
1895 listbox $w.top.databases.list -width 14 -height 5\
1896 -yscrollcommand "$w.top.databases.scroll set"
1898 scrollbar $w.top.databases.scroll -orient vertical -border 1
1899 pack $w.top.databases.label -side top -fill x \
1901 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1903 pack $w.top.databases.list -side left -fill both -expand yes \
1905 pack $w.top.databases.scroll -side right -fill y \
1907 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1909 foreach b [lindex $profile($target) 7] {
1910 $w.top.databases.list insert end $b
1914 pack $w.top.cs-type -pady 2 -padx 2 -side top -fill x
1916 label $w.top.cs-type.label -text "Transport"
1917 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1918 -variable csRadioType -value tcpip
1919 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1920 -variable csRadioType -value mosi
1922 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1923 -padx 2 -side top -fill x
1926 pack $w.top.protocol -pady 2 -padx 2 -side top -fill x
1928 label $w.top.protocol.label -text "Protocol"
1929 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1930 -variable protocolRadioType -value Z39
1931 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1932 -variable protocolRadioType -value SR
1934 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1935 -padx 2 -side top -fill x
1938 pack $w.top.query -pady 2 -padx 2 -side top -fill x
1940 label $w.top.query.label -text "Query support"
1941 checkbutton $w.top.query.c1 -text "RPN query" -anchor w -variable RPNCheck
1942 checkbutton $w.top.query.c2 -text "CCL query" -anchor w -variable CCLCheck
1943 checkbutton $w.top.query.c3 -text "Result sets" -anchor w -variable ResultSetCheck
1945 pack $w.top.query.label -side top
1946 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
1947 -padx 2 -side top -fill x
1950 bottom-buttons $w [list {Ok} [list protocol-setup-action $target $w] \
1951 {Delete} [list protocol-setup-delete $target $w] \
1952 {Cancel} [list destroy $w]] 0
1955 proc database-select-action {} {
1956 set w .database-select.top
1958 foreach indx [$w.databases.list curselection] {
1959 lappend b [$w.databases.list get $indx]
1962 z39 databaseNames $b
1964 destroy .database-select
1967 proc database-select {} {
1968 set w .database-select
1973 set oldFocus [focus]
1978 frame $w.top.databases -relief ridge -border 2
1980 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
1982 label $w.top.databases.label -text "List"
1983 listbox $w.top.databases.list -width 20 -height 6 \
1984 -yscrollcommand "$w.top.databases.scroll set"
1985 scrollbar $w.top.databases.scroll -orient vertical -border 1
1986 pack $w.top.databases.label -side top -fill x \
1988 pack $w.top.databases.list -side left -fill both -expand yes \
1990 pack $w.top.databases.scroll -side right -fill y \
1992 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1994 foreach b [lindex $profile($hostid) 7] {
1995 $w.top.databases.list insert end $b
1997 top-down-ok-cancel $w {database-select-action} 1
2001 proc cascade-target-list {} {
2004 foreach sub [winfo children .top.target.m.clist] {
2007 .top.target.m.clist delete 0 last
2008 foreach n [lsort [array names profile]] {
2009 if {$n != "Default"} {
2010 set nl [lindex $profile($n) 12]
2011 if {[llength [lindex $profile($n) 7]] > 1} {
2012 .top.target.m.clist add cascade -label $n \
2013 -menu .top.target.m.clist.$nl
2014 menu .top.target.m.clist.$nl
2015 foreach b [lindex $profile($n) 7] {
2016 .top.target.m.clist.$nl add command -label $b \
2017 -command [list reopen-target $n $b]
2020 .top.target.m.clist add command -label $n \
2021 -command [list reopen-target $n {}]
2025 .top.target.m.slist delete 0 last
2026 foreach n [lsort [array names profile]] {
2027 if {$n != "Default"} {
2028 .top.target.m.slist add command -label $n \
2029 -command [list protocol-setup $n]
2034 proc query-select {i} {
2035 global queryButtonsFind
2036 global queryInfoFind
2040 set queryInfoFind [lindex $queryInfo $i]
2041 set queryButtonsFind [lindex $queryButtons $i]
2043 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2046 proc query-new-action {} {
2050 global settingsChanged
2052 set settingsChanged 1
2053 lappend queryTypes [.query-new.top.index.entry get]
2054 lappend queryButtons {}
2055 lappend queryInfo {}
2065 set oldFocus [focus]
2070 -side top -anchor e -pady 2
2071 entry-fields $w.top index \
2073 query-new-action {destroy .query-new}
2074 top-down-ok-cancel $w query-new-action 1
2078 proc query-delete-action {queryNo} {
2082 global settingsChanged
2084 set settingsChanged 1
2086 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
2087 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
2088 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
2089 destroy .query-delete
2093 proc query-delete {queryNo} {
2101 set n [lindex $queryTypes $queryNo]
2103 label $w.top.warning -bitmap warning
2104 message $w.top.quest -text "Are you sure you want to delete the \
2105 query type $n ?" -aspect 300
2106 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
2107 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
2108 {Cancel} [list destroy $w]] 1
2111 proc cascade-query-list {} {
2113 set w .top.options.m.query
2116 $w.slist delete 0 last
2117 foreach n $queryTypes {
2118 $w.slist add command -label $n -command [list query-setup $i]
2123 $w.clist delete 0 last
2124 foreach n $queryTypes {
2125 $w.clist add command -label $n -command [list query-select $i]
2129 $w.dlist delete 0 last
2130 foreach n $queryTypes {
2131 $w.dlist add command -label $n -command [list query-delete $i]
2136 proc save-geometry {} {
2137 global windowGeometry
2140 global displayFormat
2143 global elementSetNames
2145 set windowGeometry(.) [wm geometry .]
2147 if {[catch {set f [open ~/.clientrc.tcl w]}]} {
2150 puts $f "set hotTargets \{ $hotTargets \}"
2151 puts $f "set textWrap $textWrap"
2152 puts $f "set displayFormat $displayFormat"
2153 puts $f "set popupMarcdf $popupMarcdf"
2154 puts $f "set recordSyntax $recordSyntax"
2155 puts $f "set elementSetNames $elementSetNames"
2156 foreach n [array names windowGeometry] {
2157 puts -nonewline $f "set \{windowGeometry($n)\} \{"
2158 puts -nonewline $f $windowGeometry($n)
2164 proc save-settings {} {
2167 global settingsChanged
2172 if {![file writable "${libdir}/clientrc.tcl"]} {
2173 set a [alert "Cannot open ${libdir}/clientrc.tcl for writing. Do you \
2174 wish to save clientrc.tcl in the current directory instead?"]
2178 set f [open "clientrc.tcl" w]
2180 set f [open "${libdir}/clientrc.tcl" w]
2182 puts $f "# Setup file"
2184 foreach n [array names profile] {
2185 puts -nonewline $f "set \{profile($n)\} \{"
2186 puts -nonewline $f $profile($n)
2189 puts -nonewline $f "set queryTypes \{"
2190 puts -nonewline $f $queryTypes
2193 puts -nonewline $f "set queryButtons \{"
2194 puts -nonewline $f $queryButtons
2197 puts -nonewline $f "set queryInfo \{"
2198 puts -nonewline $f $queryInfo
2201 set settingsChanged 0
2210 set oldFocus [focus]
2214 label $w.top.warning -bitmap warning
2215 message $w.top.message -text $ask -aspect 300 \
2216 -font -Adobe-Times-Medium-R-Normal-*-180-*
2218 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
2221 top-down-ok-cancel $w {alert-action} 1
2226 proc alert-action {} {
2232 proc exit-action {} {
2233 global settingsChanged
2235 if {$settingsChanged} {
2236 set a [alert "you haven't saved your settings. Do you wish to save?"]
2245 proc listbuttonaction {w name h user i} {
2246 $w configure -text [lindex $name 0]
2247 $h [lindex $name 1] $user $i
2250 proc listbuttonx {button no names handle user} {
2251 if {[winfo exists $button]} {
2252 $button configure -text [lindex [lindex $names $no] 0]
2253 ${button}.m delete 0 last
2255 menubutton $button -text [lindex [lindex $names $no] 0] \
2256 -width 10 -menu ${button}.m -relief raised -border 1
2260 foreach name $names {
2261 ${button}.m add command -label [lindex $name 0] \
2262 -command [list listbuttonaction ${button} $name \
2268 proc listbutton {button no names} {
2269 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
2270 -relief raised -border 1
2272 foreach name $names {
2273 ${button}.m add command -label $name \
2274 -command [list ${button} configure -text $name]
2278 proc listbuttonv-action {button var names i} {
2281 set $var [lindex $names [expr $i+1]]
2282 $button configure -text [lindex $names $i]
2285 proc listbuttonv {button var names} {
2289 eval "set val $$var"
2290 set l [llength $names]
2291 for {set i 1} {$i < $l} {incr i 2} {
2292 if {$val == [lindex $names $i]} {
2294 set n [lindex $names $i]
2298 if {[winfo exists $button]} {
2299 $button configure -text $n
2302 menubutton $button -text $n -menu ${button}.m \
2303 -relief raised -border 1
2305 for {set i 0} {$i < $l} {incr i 2} {
2306 ${button}.m add command -label [lindex $names $i] \
2307 -command [list listbuttonv-action $button $var $names $i]
2311 proc query-add-index-action {queryNo} {
2315 global queryButtonsTmp
2317 set newI [.query-add-index.top.index.entry get]
2318 lappend queryInfoTmp [list $newI {}]
2319 $w.top.index.list insert end $newI
2320 destroy .query-add-index
2321 #destroy $w.top.lines
2322 #frame $w.top.lines -relief ridge -border 2
2323 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2324 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2327 proc query-add-line {queryNo} {
2331 global queryButtonsTmp
2333 lappend queryButtonsTmp {I 0}
2335 #destroy $w.top.lines
2336 #frame $w.top.lines -relief ridge -border 2
2337 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2338 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2341 proc query-del-line {queryNo} {
2345 global queryButtonsTmp
2347 set l [llength $queryButtonsTmp]
2352 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
2353 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2356 proc query-add-index {queryNo} {
2357 set w .query-add-index
2360 set oldFocus [focus]
2361 place-force $w .query-setup
2365 -side top -anchor e -pady 2
2366 entry-fields $w.top {index} \
2368 [list query-add-index-action $queryNo] [list destroy $w]
2369 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
2373 proc query-setup-action {queryNo} {
2376 global queryButtonsTmp
2378 global queryButtonsFind
2379 global queryInfoFind
2381 global settingsChanged
2383 set settingsChanged 1
2385 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
2387 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
2389 set queryInfoFind $queryInfoTmp
2390 set queryButtonsFind $queryButtonsTmp
2392 destroy .query-setup
2393 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2396 proc activate-e-index {value no i} {
2397 global queryButtonsTmp
2398 global queryIndexTmp
2400 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
2401 dputs $queryButtonsTmp
2402 set queryIndexTmp $i
2405 proc activate-index {value no i} {
2406 global queryButtonsFind
2408 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
2410 dputs "queryButtonsFind $queryButtonsFind"
2413 proc update-attr {} {
2415 listbuttonv $w.top.relation.b relationTmpValue\
2416 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
2417 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
2418 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
2419 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
2420 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
2421 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
2422 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
2423 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
2424 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
2425 {local-number} 107 {string} 108 {numeric string} 109}
2426 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2427 {Left} 2 {Left and right} 3 {No truncation} 100 \
2428 {Process #} 101 {Re-1} 102 {Re-2} 103}
2429 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2430 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2433 proc use-attr {init} {
2445 {BNB card number} 10
2446 {BGF(sic) number} 11
2448 {Dewey classification} 13
2449 {UDC classification} 14
2450 {Bliss classification} 15
2452 {NLM call number} 17
2453 {NAL call number} 18
2454 {MOS call number} 19
2455 {Local classification} 20
2456 {Subject heading} 21
2458 {BDI-index-subject} 23
2462 {LC-subject-heading} 27
2463 {RVM-subject-heading} 28
2464 {Local subject index} 29
2466 {Date of publication} 31
2467 {Date of acquisition} 32
2469 {Title-collective} 34
2472 {Title-added-title-page} 37
2476 {Title-other-variant} 41
2478 {Title-abbreviated} 43
2482 {Subject-subdivision} 47
2483 {Number-natl-bibliography} 48
2484 {Number-legal-deposit} 49
2485 {Number-govt-publication} 50
2486 {Number-publisher-for-music} 51
2488 {Number-local-call} 53
2490 {Code-geographic-area} 55
2491 {Code-institution} 56
2493 {Name-geographic} 58
2494 {Place-publication} 59
2496 {Microform-generation} 61
2503 {Author-name-personal} 1004
2504 {Author-name-corporate} 1005
2505 {Author-name-conference} 1006
2506 {Identifier-standard} 1007
2507 {Subject-LC-children's} 1008
2508 {Subject-name-personal} 1009
2510 {Date/time added to database} 1011
2511 {Date/time last modified} 1012
2512 {Authority/format identifier} 1013
2514 {Concept-reference} 1015
2516 {Server choice} 1017
2518 {Record source} 1019
2521 {Geographic class} 1022
2525 {Related periodical} 1026
2526 {Report number} 1027
2528 {Thematic number} 1030
2529 {Material type} 1031
2537 set l [llength $attr]
2542 for {set i 0} {$i < $l} {incr i} {
2543 $w.top.use.list insert end [lindex $attr $i]
2545 if {$useTmpValue == [lindex $attr $i]} {
2551 $w.top.use.list selection clear 0 end
2552 $w.top.use.list selection set $s $s
2554 $w.top.use.list select from $s
2555 $w.top.use.list select to $s
2561 $w.top.use.list yview $s
2563 set lno [lindex [$w.top.use.list curselection] 0]
2564 set i [expr $lno+$lno+1]
2565 set useTmpValue [lindex $attr $i]
2566 dputs "useTmpValue=$useTmpValue"
2570 proc index-setup-action {oldAttr queryNo indexNo} {
2571 set attr [lindex $oldAttr 0]
2574 global relationTmpValue
2575 global structureTmpValue
2576 global truncationTmpValue
2577 global completenessTmpValue
2578 global positionTmpValue
2583 dputs "index-setup-action"
2584 dputs "queryNo $queryNo"
2585 dputs "indexNo $indexNo"
2586 if {$useTmpValue > 0} {
2587 lappend attr "1=$useTmpValue"
2589 if {$relationTmpValue > 0} {
2590 lappend attr "2=$relationTmpValue"
2592 if {$positionTmpValue > 0} {
2593 lappend attr "3=$positionTmpValue"
2595 if {$structureTmpValue > 0} {
2596 lappend attr "4=$structureTmpValue"
2598 if {$truncationTmpValue > 0} {
2599 lappend attr "5=$truncationTmpValue"
2601 if {$completenessTmpValue > 0} {
2602 lappend attr "6=$completenessTmpValue"
2604 dputs "new attr $attr"
2605 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2606 destroy .index-setup
2609 proc index-setup {attr queryNo indexNo} {
2612 global relationTmpValue
2613 global structureTmpValue
2614 global truncationTmpValue
2615 global completenessTmpValue
2616 global positionTmpValue
2618 set relationTmpValue 0
2619 set truncationTmpValue 0
2620 set structureTmpValue 0
2621 set positionTmpValue 0
2622 set completenessTmpValue 0
2628 set n [lindex $attr 0]
2629 wm title $w "Index setup $n"
2633 set len [llength $attr]
2634 for {set i 1} {$i < $len} {incr i} {
2635 set q [lindex $attr $i]
2636 set l [string first = $q]
2638 set t [string range $q 0 [expr $l - 1]]
2639 set v [string range $q [expr $l + 1] end]
2642 { set useTmpValue $v }
2644 { set relationTmpValue $v }
2646 { set positionTmpValue $v }
2648 { set structureTmpValue $v }
2650 { set truncationTmpValue $v }
2652 { set completenessTmpValue $v }
2657 frame $w.top.use -relief ridge -border 2
2658 frame $w.top.relation -relief ridge -border 2
2659 frame $w.top.position -relief ridge -border 2
2660 frame $w.top.structure -relief ridge -border 2
2661 frame $w.top.truncation -relief ridge -border 2
2662 frame $w.top.completeness -relief ridge -border 2
2668 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2670 label $w.top.use.label -text "Use"
2672 listbox $w.top.use.list -width 26 \
2673 -yscrollcommand "$w.top.use.scroll set"
2675 listbox $w.top.use.list -geometry 26x10 \
2676 -yscrollcommand "$w.top.use.scroll set"
2678 scrollbar $w.top.use.scroll -orient vertical -border 1
2679 pack $w.top.use.label -side top -fill x \
2681 pack $w.top.use.list -side left -fill both -expand yes \
2683 pack $w.top.use.scroll -side right -fill y \
2685 $w.top.use.scroll config -command "$w.top.use.list yview"
2689 # Relation Attributes
2691 pack $w.top.relation -pady 6 -padx 6 -side top
2692 label $w.top.relation.label -text "Relation" -width 18
2694 pack $w.top.relation.label $w.top.relation.b -fill x
2696 # Position Attributes
2698 pack $w.top.position -pady 6 -padx 6 -side top
2699 label $w.top.position.label -text "Position" -width 18
2701 pack $w.top.position.label $w.top.position.b -fill x
2703 # Structure Attributes
2705 pack $w.top.structure -pady 6 -padx 6 -side top
2706 label $w.top.structure.label -text "Structure" -width 18
2708 pack $w.top.structure.label $w.top.structure.b -fill x
2710 # Truncation Attributes
2712 pack $w.top.truncation -pady 6 -padx 6 -side top
2713 label $w.top.truncation.label -text "Truncation" -width 18
2715 pack $w.top.truncation.label $w.top.truncation.b -fill x
2717 # Completeness Attributes
2719 pack $w.top.completeness -pady 6 -padx 6 -side top
2720 label $w.top.completeness.label -text "Completeness" -width 18
2722 pack $w.top.completeness.label $w.top.completeness.b -fill x
2725 bottom-buttons $w [list \
2726 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2727 {Cancel} [list destroy $w]] 0
2731 proc query-edit-index {queryNo} {
2735 set i [lindex [$w.top.index.list curselection] 0]
2739 set attr [lindex $queryInfoTmp $i]
2740 dputs "Editing no $i $attr"
2741 index-setup $attr $queryNo $i
2744 proc query-delete-index {queryNo} {
2746 global queryButtonsTmp
2749 set i [lindex [$w.top.index.list curselection] 0]
2753 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2754 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2755 $w.top.index.list delete $i
2758 proc query-setup {queryNo} {
2764 global queryButtonsTmp
2766 global queryIndexTmp
2769 set queryName [lindex $queryTypes $queryNo]
2770 set queryInfoTmp [lindex $queryInfo $queryNo]
2771 set queryButtonsTmp [lindex $queryButtons $queryNo]
2776 wm title $w "Query setup $queryName"
2780 frame $w.top.lines -relief ridge -border 2
2782 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2786 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2788 button $w.top.lines.add -text "Add" \
2789 -command [list query-add-line $queryNo]
2790 button $w.top.lines.del -text "Remove" \
2791 -command [list query-del-line $queryNo]
2793 pack $w.top.lines.del -fill x -side bottom
2794 pack $w.top.lines.add -fill x -pady 10 -side bottom
2798 frame $w.top.index -relief ridge -border 2
2799 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2801 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2802 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2803 -command [list $w.top.index.list yview]
2804 bind $w.top.index.list <Double-1> [list query-edit-index $queryNo]
2806 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2807 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2810 $w.top.index.list selection clear 0 end
2811 $w.top.index.list selection set 0 0
2813 $w.top.index.list select from 0
2814 $w.top.index.list select to 0
2817 foreach x $queryInfoTmp {
2818 $w.top.index.list insert end [lindex $x 0]
2822 bottom-buttons $w [list \
2823 Ok [list query-setup-action $queryNo] \
2824 Add [list query-add-index $queryNo] \
2825 Edit [list query-edit-index $queryNo] \
2826 Delete [list query-delete-index $queryNo] \
2827 Cancel [list destroy $w]] 0
2830 proc index-clear {} {
2831 global queryButtonsFind
2834 foreach b $queryButtonsFind {
2835 .lines.$i.e delete 0 end
2840 proc index-query {} {
2841 global queryButtonsFind
2842 global queryInfoFind
2847 foreach b $queryButtonsFind {
2848 set term [string trim [.lines.$i.e get]]
2850 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
2853 set len [string length $term]
2857 if {[string index $term 0] == ">"} {
2858 if {[string index $term 1] == "=" } {
2859 set term [string trim [string range $term 2 $len]]
2862 set term [string trim [string range $term 1 $len]]
2865 } elseif {[string index $term 0] == "<"} {
2866 if {[string index $term 1] == "=" } {
2867 set term [string trim [string range $term 2 $len]]
2869 } elseif {[string index $term 1] == ">"} {
2870 set term [string trim [string range $term 2 $len]]
2873 set term [string trim [string range $term 1 $len]]
2878 set len [string length $term]
2882 if {[string index $term $len] == "?"} {
2884 set term [string range $term 0 [expr $len - 1]]
2886 if {[string index $term 0] == "?"} {
2888 set term [string range $term 1 end]
2890 set term "\{${term}\}"
2891 if {$right && $left} {
2892 set term "@attr 5=3 ${term}"
2894 set term "@attr 5=1 ${term}"
2896 set term "@attr 5=2 ${term}"
2898 if {$relation != ""} {
2899 set term "@attr 2=${relation} ${term}"
2902 set term "@attr $a ${term}"
2905 set qs "@and ${qs} ${term}"
2916 proc index-focus-in {w i} {
2917 global curIndexEntry
2920 $w.$i configure -background red
2922 set curIndexEntry $i
2925 proc index-lines {w realOp buttonInfo queryInfo handle} {
2927 foreach b $buttonInfo {
2928 if {! [winfo exists $w.$i]} {
2930 frame $w.$i -border 0
2932 frame $w.$i -background white -border 1
2935 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
2938 if {! [winfo exists $w.$i.e]} {
2939 entry $w.$i.e -width 32 -relief sunken -border 1
2940 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
2941 bind $w.$i.e <FocusOut> [list $w.$i configure \
2943 pack $w.$i.l -side left
2944 pack $w.$i.e -side left -fill x -expand yes
2945 pack $w.$i -side top -fill x -padx 2 -pady 2
2947 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2948 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2950 bind $w.$i.e <Return> {search-request 0}
2953 pack $w.$i.l -side left
2954 pack $w.$i -side top -fill x -padx 2 -pady 2
2959 while {[winfo exists $w.$j]} {
2971 bind $w.$j.e <Tab> "focus $w.$k.e"
2977 bind $w.$i.e <Tab> "focus $w.0.e"
2983 proc search-fields {w buttondefs} {
2985 foreach buttondef $buttondefs {
2986 frame $w.$i -background white
2988 listbutton $w.$i.l 0 $buttondef
2989 entry $w.$i.e -width 32 -relief sunken
2991 pack $w.$i.l -side left
2992 pack $w.$i.e -side left -fill x -expand yes
2994 pack $w.$i -side top -fill x -padx 2 -pady 2
2996 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2997 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
3005 bind $w.$j.e <Tab> "focus $w.$k.e \n
3006 $w.$k configure -background red \n
3007 $w.$j configure -background white"
3010 bind $w.$i.e <Tab> "focus $w.0.e \n
3011 $w.0 configure -background red \n
3012 $w.$i configure -background white"
3014 $w.0 configure -background red
3017 if {[info exists windowGeometry(.)]} {
3018 set g $windowGeometry(.)
3026 frame .top -border 1 -relief raised
3027 frame .lines -border 1 -relief raised
3028 frame .mid -border 1 -relief raised
3029 frame .data -border 1 -relief raised
3030 frame .bot -border 1 -relief raised
3031 pack .top .lines .mid -side top -fill x
3032 pack .data -side top -fill both -expand yes
3035 menubutton .top.file -text "File" -menu .top.file.m
3037 .top.file.m add command -label "Save settings" -command {save-settings}
3038 .top.file.m add separator
3039 .top.file.m add command -label "Exit" -command {exit-action}
3041 menubutton .top.target -text "Target" -menu .top.target.m
3043 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
3044 .top.target.m add command -label "Disconnect" -command {close-target}
3045 .top.target.m add command -label "About" -command {about-target}
3046 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
3047 .top.target.m add command -label "Setup new" -command {define-target-dialog}
3048 .top.target.m add separator
3049 set-target-hotlist 0
3051 configure-disable-e .top.target.m 1
3052 configure-disable-e .top.target.m 2
3054 menu .top.target.m.clist
3055 menu .top.target.m.slist
3058 menubutton .top.service -text "Service" -menu .top.service.m
3060 .top.service.m add command -label "Database" -command {database-select}
3061 .top.service.m add cascade -label "Present" -menu .top.service.m.present
3062 menu .top.service.m.present
3063 .top.service.m.present add command -label "10 More" \
3064 -command [list present-more 10]
3065 .top.service.m.present add command -label "All" \
3066 -command [list present-more {}]
3067 .top.service.m add command -label "Search" -command {search-request 0}
3068 .top.service.m add command -label "Scan" -command {scan-request}
3070 .top.service configure -state disabled
3072 menubutton .top.rset -text "Set" -menu .top.rset.m
3074 .top.rset.m add command -label "Load" -command {load-set}
3075 .top.rset.m add separator
3077 menubutton .top.options -text "Options" -menu .top.options.m
3079 .top.options.m add cascade -label "Query" -menu .top.options.m.query
3080 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
3081 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
3082 .top.options.m add cascade -label "Syntax" -menu .top.options.m.syntax
3083 .top.options.m add cascade -label "Elements" -menu .top.options.m.elements
3085 menu .top.options.m.query
3086 .top.options.m.query add cascade -label "Select" \
3087 -menu .top.options.m.query.clist
3088 .top.options.m.query add cascade -label "Edit" \
3089 -menu .top.options.m.query.slist
3090 .top.options.m.query add command -label "New" \
3091 -command {query-new}
3092 .top.options.m.query add cascade -label "Delete" \
3093 -menu .top.options.m.query.dlist
3095 menu .top.options.m.query.slist
3096 menu .top.options.m.query.clist
3097 menu .top.options.m.query.dlist
3100 menu .top.options.m.formats
3102 foreach f $displayFormats {
3103 .top.options.m.formats add radiobutton -label $f -value $i \
3104 -command [list set-display-format $i] -variable displayFormat
3108 menu .top.options.m.wrap
3109 .top.options.m.wrap add radiobutton -label "Character" \
3110 -value char -variable textWrap -command {set-wrap char}
3111 .top.options.m.wrap add radiobutton -label "Word" \
3112 -value word -variable textWrap -command {set-wrap word}
3113 .top.options.m.wrap add radiobutton -label "None" \
3114 -value none -variable textWrap -command {set-wrap none}
3116 menu .top.options.m.syntax
3117 .top.options.m.syntax add radiobutton -label "None" \
3118 -value None -variable recordSyntax
3119 .top.options.m.syntax add separator
3120 .top.options.m.syntax add radiobutton -label "USMARC" \
3121 -value USMARC -variable recordSyntax
3122 .top.options.m.syntax add radiobutton -label "UNIMARC" \
3123 -value UNIMARC -variable recordSyntax
3124 .top.options.m.syntax add radiobutton -label "UKMARC" \
3125 -value UKMARC -variable recordSyntax
3126 .top.options.m.syntax add radiobutton -label "DANMARC" \
3127 -value DANMARC -variable recordSyntax
3128 .top.options.m.syntax add radiobutton -label "FINMARC" \
3129 -value FINMARC -variable recordSyntax
3130 .top.options.m.syntax add radiobutton -label "NORMARC" \
3131 -value NORMARC -variable recordSyntax
3132 .top.options.m.syntax add radiobutton -label "PICAMARC" \
3133 -value PICAMARC -variable recordSyntax
3134 .top.options.m.syntax add separator
3135 .top.options.m.syntax add radiobutton -label "SUTRS" \
3136 -value SUTRS -variable recordSyntax
3137 .top.options.m.syntax add separator
3138 .top.options.m.syntax add radiobutton -label "GRS1" \
3139 -value GRS1 -variable recordSyntax
3141 menu .top.options.m.elements
3142 .top.options.m.elements add radiobutton -label "Unspecified" \
3143 -value None -variable elementSetNames
3144 .top.options.m.elements add radiobutton -label "Full" \
3145 -value F -variable elementSetNames
3146 .top.options.m.elements add radiobutton -label "Brief" \
3147 -value B -variable elementSetNames
3149 menubutton .top.help -text "Help" -menu .top.help.m
3152 .top.help.m add command -label "Help on help" \
3153 -command {tkerror "Help on help not available. Sorry"}
3154 .top.help.m add command -label "About" -command {about-origin}
3156 pack .top.file .top.target .top.service .top.rset .top.options -side left
3157 pack .top.help -side right
3159 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
3161 button .mid.search -text Search -command {search-request 0} \
3163 button .mid.scan -text Scan \
3164 -command scan-request -state disabled
3165 button .mid.present -text {Present} -command [list present-more 10] \
3168 button .mid.clear -text Clear -command index-clear
3169 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
3172 text .data.record -height 2 -width 20 -wrap none \
3173 -yscrollcommand [list .data.scroll set] -wrap $textWrap
3174 scrollbar .data.scroll -command [list .data.record yview]
3176 .data.record configure -takefocus 0
3177 .data.scroll configure -takefocus 0
3179 pack .data.scroll -side right -fill y
3180 pack .data.record -expand yes -fill both
3184 .data.record tag configure marc-tag -foreground blue
3185 .data.record tag configure marc-id -foreground red
3187 .data.record tag configure marc-tag -foreground black
3188 .data.record tag configure marc-id -foreground black
3190 .data.record tag configure marc-data -foreground black
3191 .data.record tag configure marc-head \
3192 -font -Adobe-Times-Bold-R-Normal-*-140-* \
3193 -foreground brown -relief raised -borderwidth 1
3194 .data.record tag configure marc-small-head -foreground brown
3195 .data.record tag configure marc-pref \
3196 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3198 .data.record tag configure marc-text \
3199 -font -Adobe-Times-Medium-R-Normal-*-140-* \
3201 .data.record tag configure marc-it \
3202 -font -Adobe-Times-Medium-I-Normal-*-140-* \
3205 button .bot.logo -bitmap @${libdir}/bitmaps/book1 -command cancel-operation
3207 .bot.logo configure -takefocus 0
3210 pack .bot.a -side left -fill x
3211 pack .bot.logo -side right -padx 2 -pady 2 -ipadx 1
3213 message .bot.a.target -text "" -aspect 1000 -border 1
3215 label .bot.a.status -text "Not connected" -width 15 -relief \
3216 sunken -anchor w -border 1
3217 label .bot.a.set -text "" -width 5 -relief \
3218 sunken -anchor w -border 1
3219 label .bot.a.message -text "" -width 15 -relief \
3220 sunken -anchor w -border 1
3222 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
3223 pack .bot.a.status .bot.a.set .bot.a.message \
3224 -side left -padx 2 -pady 2 -ipadx 1 -ipady 1
3226 if {[catch {ir z39}]} {
3227 set e [info sharedlibextension]
3228 puts -nonewline "Loading irtcl$e ..."
3233 z39 largeSetLowerBound 20
3234 z39 smallSetUpperBound 2
3235 z39 mediumSetPresentNumber 2