1 # IR toolkit for tcl/tk
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
7 # Revision 1.46 1995-06-19 13:06:06 adam
8 # New define: IR_TCL_VERSION.
10 # Revision 1.45 1995/06/19 08:08:44 adam
11 # client.tcl: hotTargets now contain both database and target name.
12 # ir-tcl.c: setting protocol edited. Errors in callbacks are logged
13 # by logf(LOG_WARN, ...) calls.
15 # Revision 1.44 1995/06/16 14:55:18 adam
18 # Revision 1.43 1995/06/16 14:41:05 adam
19 # Scan line entries can be copied to a search entry.
21 # Revision 1.42 1995/06/16 12:28:13 adam
22 # Implemented preferredRecordSyntax.
23 # Minor changes in diagnostic handling.
24 # Record list deleted when connection closes.
26 # Revision 1.41 1995/06/14 15:07:59 adam
27 # Bug fix in cascade-target-list. Uses yaz-version.h.
29 # Revision 1.40 1995/06/14 13:37:17 adam
30 # Setting recordType implemented.
31 # Setting implementationVersion implemented.
32 # Settings implementationId / implementationName edited.
34 # Revision 1.39 1995/06/14 12:16:22 adam
35 # hotTargets, textWrap and displayFormat saved in clientg.tcl.
37 # Revision 1.38 1995/06/14 07:22:45 adam
38 # Target definitions can be deleted.
39 # Listbox used in the query definition dialog.
41 # Revision 1.37 1995/06/13 14:37:59 adam
42 # Work on query setup.
43 # Better about origin/target.
44 # Better presentation formats.
46 # Revision 1.36 1995/06/13 07:42:14 adam
47 # Bindings removed from text widgets.
49 # Revision 1.35 1995/06/12 15:17:31 adam
50 # Text widget used in main window (instead of listbox) to support
51 # better presentation formats.
53 # Revision 1.34 1995/06/12 07:59:07 adam
54 # More work on geometry handling.
56 # Revision 1.33 1995/06/09 11:17:35 adam
57 # Start work on geometry management.
59 # Revision 1.32 1995/06/07 09:16:37 adam
60 # New presentation format.
62 # Revision 1.31 1995/06/06 16:31:09 adam
63 # Bug fix: target names couldn't contain blanks.
66 # Revision 1.30 1995/06/06 11:35:41 adam
67 # Work on scan. Display of old sets.
69 # Revision 1.29 1995/06/05 14:11:18 adam
70 # Bug fix in present-more.
72 # Revision 1.28 1995/06/02 14:52:13 adam
73 # Minor changes really.
75 # Revision 1.27 1995/06/02 14:29:42 adam
76 # Work on scan interface - up/down buttons.
78 # Revision 1.26 1995/06/01 16:36:46 adam
79 # About buttons. Minor bug fixes.
81 # Revision 1.25 1995/05/31 13:09:57 adam
82 # Client searches/presents may be interrupted.
83 # New moving book-logo.
85 # Revision 1.24 1995/05/31 08:36:24 adam
86 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
87 # New method: referenceId. More work on scan.
89 # Revision 1.23 1995/05/29 10:33:41 adam
90 # README and rename of startup script.
92 # Revision 1.22 1995/05/26 11:44:09 adam
93 # Bugs fixed. More work on MARC utilities and queries. Test
94 # client is up-to-date again.
96 # Revision 1.21 1995/05/11 15:34:46 adam
97 # Scan request changed a bit. This version works with RLG.
99 # Revision 1.20 1995/04/21 16:31:57 adam
100 # New radiobutton: protocol (z39v2/SR).
102 # Revision 1.19 1995/04/18 16:11:50 adam
103 # First version of graphical Scan. Some work on query-by-form.
105 # Revision 1.18 1995/04/10 10:50:22 adam
106 # Result-set name defaults to suffix of ir-set name.
107 # Started working on scan. Not finished at this point.
109 # Revision 1.17 1995/03/31 09:34:57 adam
110 # Search-button disabled when there is no connection.
112 # Revision 1.16 1995/03/31 08:56:36 adam
113 # New button "Search".
115 # Revision 1.15 1995/03/28 12:45:22 adam
116 # New ir method failback: called on disconnect/protocol error.
117 # New ir set/get method: protocol: SR / Z3950.
118 # Simple popup and disconnect when failback is invoked.
120 # Revision 1.14 1995/03/22 16:07:55 adam
123 # Revision 1.13 1995/03/21 17:27:26 adam
124 # Short-hand keys in setup.
126 # Revision 1.12 1995/03/21 13:41:03 adam
127 # Comstack cs_create not used too often. Non-blocking connect.
129 # Revision 1.11 1995/03/21 10:39:06 adam
130 # Diagnostic error message displayed with tkerror.
132 # Revision 1.10 1995/03/20 15:24:06 adam
133 # Diagnostic records saved on searchResponse.
135 # Revision 1.9 1995/03/17 18:26:16 adam
136 # Non-blocking i/o used now. Database names popup as cascade items.
138 # Revision 1.8 1995/03/17 15:45:00 adam
139 # Improved target/database setup.
141 # Revision 1.7 1995/03/16 17:54:03 adam
142 # Minor changes really.
144 # Revision 1.6 1995/03/15 19:10:20 adam
145 # Database setup in protocol-setup (rather target setup).
147 # Revision 1.5 1995/03/15 13:59:23 adam
150 # Revision 1.4 1995/03/14 17:32:29 adam
151 # Presentation of full Marc record in popup window.
153 # Revision 1.3 1995/03/12 19:31:52 adam
154 # Pattern matching implemented when retrieving MARC records. More
155 # diagnostic functions.
157 # Revision 1.2 1995/03/10 18:00:15 adam
158 # Actual presentation in line-by-line format. RPN query support.
160 # Revision 1.1 1995/03/09 16:15:07 adam
161 # First presentRequest attempts. Hot-target list.
170 set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} Z39}
172 set settingsChanged 0
183 set queryTypes {Simple}
184 set queryButtons { { {I 0} {I 1} {I 2} } }
185 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
186 {Subject {1=21}} {Any {1=1016}} } }
192 proc read-formats {} {
193 global displayFormats
194 set formats [glob -nocomplain formats/*.tcl]
197 set l [expr [string length $f] - 5]
198 lappend displayFormats [string range $f 8 $l]
206 .data.record configure -wrap $m
213 proc set-display-format {f} {
223 .bot.a.status configure -text "Reformatting"
226 add-title-lines 0 10000 1
228 .bot.a.status configure -text "Ready"
232 proc initBindings {} {
235 bind $w <Double-1> {}
236 bind $w <Triple-1> {}
237 bind $w <B1-Motion> {}
239 bind $w <Shift-B1-Motion> {}
241 bind $w <B2-Motion> {}
242 bind $w <Any-KeyPress> {}
244 bind $w <BackSpace> {}
246 bind $w <Control-h> {}
247 bind $w <Control-d> {}
248 bind $w <Control-v> {}
251 bind $w <B1-Motion> {}
252 bind $w <Shift-B1-Motion> {}
257 proc post-menu {wbutton wmenu} {
260 $wmenu post [winfo rootx $wbutton] \
261 [expr [winfo rooty $wbutton]+[winfo height $wbutton]]
266 global windowGeometry
267 set windowGeometry($w) [wm geometry $w]
270 global windowGeometry
273 if {[info exists windowGeometry($w)]} {
274 set g $windowGeometry($w)
279 bind $w <Destroy> [list destroyGW $w]
282 if {[file readable "clientrc.tcl"]} {
283 source "clientrc.tcl"
286 if {[file readable "clientg.tcl"]} {
290 set queryButtonsFind [lindex $queryButtons 0]
291 set queryInfoFind [lindex $queryInfo 0]
293 proc top-down-window {w} {
294 frame $w.top -relief raised -border 1
295 frame $w.bot -relief raised -border 1
297 pack $w.top -side top -fill both -expand yes
298 pack $w.bot -fill both
301 proc top-down-ok-cancel {w ok-action g} {
302 frame $w.bot.left -relief sunken -border 1
303 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 5 -pady 5
304 button $w.bot.left.ok -width 6 -text {Ok} \
305 -command ${ok-action}
306 pack $w.bot.left.ok -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3
307 button $w.bot.cancel -width 6 -text {Cancel} \
308 -command [list destroy $w]
309 pack $w.bot.cancel -side left -expand yes
317 proc bottom-buttons {w buttonList g} {
319 set l [llength $buttonList]
321 frame $w.bot.$i -relief sunken -border 1
322 pack $w.bot.$i -side left -expand yes -padx 5 -pady 5
323 button $w.bot.$i.ok -text [lindex $buttonList $i] \
324 -command [lindex $buttonList [expr $i+1]]
325 pack $w.bot.$i.ok -expand yes -ipadx 3 -ipady 2 -padx 3 -pady 3 -side left
329 button $w.bot.$i -text [lindex $buttonList $i] \
330 -command [lindex $buttonList [expr $i+1]]
331 pack $w.bot.$i -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3 -side left
341 proc cancel-operation {} {
347 show-status Canceling 0 {}
351 proc show-target {target base} {
355 .bot.a.target configure -text ""
359 .bot.a.target configure -text "$target"
361 .bot.a.target configure -text "$target - $base"
365 proc show-logo {v1} {
372 .bot.logo configure -bitmap @book${v1}
373 after 140 [list show-logo $v1]
377 .bot.logo configure -bitmap @book1
386 proc show-status {status b sb} {
394 .bot.a.status configure -text "$status"
396 if {$busy == 0} {set busy 1}
404 .top.service configure -state normal
405 .mid.search configure -state normal
407 .mid.scan configure -state normal
410 .top.service.m disable 1
411 } elseif {$setOffset > 0 && $setOffset <= [z39.$setNo resultCount]} {
412 .top.service.m enable 1
413 .mid.present configure -state normal
415 .top.service.m disable 1
417 if {[winfo exists .scan-window]} {
418 .scan-window.bot.2 configure -state normal
419 .scan-window.bot.4 configure -state normal
423 .top.service configure -state disabled
424 .mid.search configure -state disabled
425 .mid.scan configure -state disabled
426 .mid.present configure -state disabled
428 if {[winfo exists .scan-window]} {
429 .scan-window.bot.2 configure -state disabled
430 .scan-window.bot.4 configure -state disabled
436 proc show-message {msg} {
437 .bot.a.message configure -text "$msg"
440 proc insertWithTags {w text args} {
441 set start [$w index insert]
442 $w insert insert $text
443 foreach tag [$w tag names $start] {
444 $w tag remove $tag $start insert
447 $w tag add $i $start insert
451 proc popup-license {} {
455 wm title $w "License"
461 text $w.top.t -width 80 -height 10 -wrap word \
462 -yscrollcommand [list $w.top.s set]
463 scrollbar $w.top.s -command [list $w.top.t yview]
465 pack $w.top.s -side right -fill y
466 pack $w.top.t -expand yes -fill both
468 set f [open "LICENSE" r]
469 while {[gets $f buf] != -1} {
470 $w.top.t insert end $buf
471 $w.top.t insert end "\n"
474 bottom-buttons $w [list {Close} [list destroy $w]] 1
477 proc about-target {} {
478 set w .about-target-w
483 wm title $w "About target"
486 frame $w.top.a -relief ridge -border 2
487 frame $w.top.p -relief ridge -border 2
489 pack $w.top.a $w.top.p -side top -fill x
491 label $w.top.a.about -text "About"
492 label $w.top.a.irtcl -text $hostid \
493 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
494 pack $w.top.a.about $w.top.a.irtcl -side top
496 set i [z39 targetImplementationName]
497 label $w.top.p.in -text "Implementation name: $i"
498 set i [z39 targetImplementationId]
499 label $w.top.p.ii -text "Implementation id: $i"
500 set i [z39 targetImplementationVersion]
501 label $w.top.p.iv -text "Implementation version: $i"
503 label $w.top.p.op -text "Protocol options: $i"
505 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
507 bottom-buttons $w [list {Close} [list destroy $w]] 1
510 proc about-origin-logo {n} {
511 set w .about-origin-w
512 if {![winfo exists $w]} {
519 $w.top.a.logo configure -bitmap @book$n
520 after 140 [list about-origin-logo $n]
523 proc about-origin {} {
524 set w .about-origin-w
526 if {[winfo exists $w]} {
531 wm title $w "About IrTcl"
535 frame $w.top.a -relief ridge -border 2
536 frame $w.top.p -relief ridge -border 2
538 pack $w.top.a $w.top.p -side top -fill x
540 label $w.top.a.irtcl -text "IrTcl" \
541 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
542 label $w.top.a.logo -bitmap @book1
543 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
545 set i [z39 implementationName]
546 label $w.top.p.in -text "Implementation name: $i"
547 set i [z39 implementationId]
548 label $w.top.p.ii -text "Implementation id: $i"
549 set i [z39 implementationVersion]
550 label $w.top.p.iv -text "Implementation version: $i"
552 pack $w.top.p.in $w.top.p.ii $w.top.p.iv -side top -anchor nw
555 bottom-buttons $w [list {Close} [list destroy $w] \
556 {License} [list popup-license]] 0
559 proc popup-marc {sno no b df} {
561 global displayFormats
564 if {[z39.$sno type $no] != "DB"} {
568 set w .full-marc-$fullMarcSeq
575 if {[winfo exists $w]} {
583 frame $w.top -relief raised -border 1
584 frame $w.bot -relief raised -border 1
586 pack $w.top -side top -fill both -expand yes
587 pack $w.bot -fill both
589 text $w.top.record -width 60 -height 5 -wrap word \
590 -yscrollcommand [list $w.top.s set]
591 scrollbar $w.top.s -command [list $w.top.record yview]
593 if {[tk colormodel .] == "color"} {
594 $w.top.record tag configure marc-tag -foreground blue
595 $w.top.record tag configure marc-id -foreground red
597 $w.top.record tag configure marc-tag -foreground black
598 $w.top.record tag configure marc-id -foreground black
600 $w.top.record tag configure marc-data -foreground black
603 $w.top.record delete 0.0 end
604 set recordType [z39.$sno recordType $no]
605 wm title $w "$recordType record #$no"
607 set ffunc [lindex $displayFormats $df]
608 set ffunc "display-$ffunc"
610 $ffunc $sno $no $w.top.record 0
613 bind $w.top.record <Return> {destroy .full-marc}
615 pack $w.top.s -side right -fill y
616 pack $w.top.record -expand yes -fill both
619 bottom-buttons $w [list \
620 {Close} [list destroy $w]] 0
622 bottom-buttons $w [list \
623 {Close} [list destroy $w] \
624 {Duplicate} [list popup-marc $sno $no 1 0]] 0
625 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m
626 menu $w.bot.formats.m
628 foreach f $displayFormats {
629 $w.bot.formats.m add radiobutton -label $f \
630 -variable popupMarcdf -value $i \
631 -command [list display-$f $sno $no $w.top.record 0]
634 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 \
635 -padx 3 -pady 3 -side left
639 foreach f $displayFormats {
640 $w.bot.formats.m entryconfigure $i \
641 -command [list display-$f $sno $no $w.top.record 0]
647 proc update-target-hotlist {target base} {
650 set len [llength $hotTargets]
652 .top.target.m delete 6 [expr 6+[llength $hotTargets]]
655 foreach e $hotTargets {
656 if {$target == [lindex $e 0] && $base == [lindex $e 1]} {
657 set hotTargets [lreplace $hotTargets $i $i]
662 set hotTargets [linsert $hotTargets 0 [list $target $base]]
666 proc set-target-hotlist {} {
670 foreach e $hotTargets {
671 set target [lindex $e 0]
672 set base [lindex $e 1]
674 .top.target.m add command -label "$i $target" -command \
675 [list reopen-target $target {}]
677 .top.target.m add command -label "$i $target - $base" -command \
678 [list reopen-target $target $base]
687 proc reopen-target {target base} {
689 open-target $target $base
690 update-target-hotlist $target $base
693 proc define-target-action {} {
696 set target [.target-define.top.target.entry get]
700 foreach n [array names profile] {
706 set seq [lindex $profile(Default) 12]
708 set profile($target) $profile(Default)
709 set profile(Default) [lreplace $profile(Default) 12 12 [incr seq]]
711 protocol-setup $target
712 destroy .target-define
715 proc fail-response {target} {
717 tkerror "Target connection closed or protocol error"
720 proc connect-response {target base} {
721 dputs "connect-response"
722 show-target $target $base
726 proc open-target {target base} {
731 z39 comstack [lindex $profile($target) 6]
732 z39 protocol [lindex $profile($target) 11]
733 z39 idAuthentication [lindex $profile($target) 3]
734 z39 maximumRecordSize [lindex $profile($target) 4]
735 z39 preferredMessageSize [lindex $profile($target) 5]
736 dputs "maximumRecordSize="
737 dputs [z39 maximumRecordSize]
738 dputs "preferredMessageSize="
739 dputs [z39 preferredMessageSize]
740 show-status {Connecting} 1 0
742 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
744 z39 databaseNames $base
746 z39 failback [list fail-response $target]
747 z39 callback [list connect-response $target $base]
750 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
753 tkerror $errorMessage
754 show-status Ready 0 {}
757 # z39 options search present scan namedResultSets triggerResourceCtrl
759 .top.target.m disable 0
760 .top.target.m enable 1
761 .top.target.m enable 2
764 proc close-target {} {
771 .bot.a.set configure -text ""
775 show-status {Not connected} 0 0
778 .top.target.m disable 1
779 .top.target.m disable 2
780 .top.target.m enable 0
783 proc load-set-action {} {
787 ir-set z39.$setNo z39
789 set fname [.load-set.top.filename.entry get]
792 show-status {Loading} 1 {}
794 z39.$setNo loadFile $fname
796 set no [z39.$setNo numberOfRecordsReturned]
797 add-title-lines $setNo $no 1
799 set l [format "%-4d %7d" $setNo $no]
800 .top.rset.m add command -label $l \
801 -command [list add-title-lines $setNo 10000 1]
802 show-status {Ready} 0 {}
814 frame $w.top.filename
815 pack $w.top.filename -side top -anchor e -pady 2
817 entry-fields $w.top {filename} \
819 {load-set-action} {destroy .load-set}
821 top-down-ok-cancel $w {load-set-action} 1
825 proc init-request {} {
833 z39 callback {init-response}
834 show-status {Initializing} 1 {}
835 set err [catch {z39 init} errorMessage]
837 tkerror $errorMessage
838 show-status Ready 0 {}
842 proc init-response {} {
850 if {![z39 initResult]} {
851 show-status {Ready} 0 1
852 set u [z39 userInformationField]
854 tkerror "Connection rejected by target: $u"
856 if {[lsearch [z39 options] scan] >= 0} {
861 show-status {Ready} 0 1
865 proc search-request {} {
875 if {$searchEnable == 0} {
878 set query [index-query]
883 ir-set z39.$setNo z39
884 z39.$setNo preferredRecordSyntax SUTRS
886 if {[lindex $profile($target) 10] == 1} {
887 z39.$setNo setName $setNo
888 dputs "setName=${setNo}"
890 z39.$setNo setName Default
891 dputs "setName=Default"
893 if {[lindex $profile($target) 8] == 1} {
894 z39.$setNo queryType rpn
896 if {[lindex $profile($target) 9] == 1} {
897 z39.$setNo queryType ccl
899 z39 callback {search-response}
900 z39.$setNo search $query
901 show-status {Searching} 1 0
904 proc scan-copy {y entry} {
906 set no [$w.top.list nearest $y]
908 .lines.$entry.e delete 0 end
909 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
912 proc scan-request {} {
920 global queryButtonsFind
927 set b [lindex $queryButtonsFind $curIndexEntry]
929 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
930 set attr "@attr $a $attr"
932 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
935 if {![winfo exists $w]} {
942 entry $w.top.entry -relief sunken
943 pack $w.top.entry -fill x -padx 4 -pady 2
944 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
946 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
948 scrollbar $w.top.scroll -orient vertical -border 1
949 pack $w.top.list -side left -fill both -expand yes
950 pack $w.top.scroll -side right -fill y
951 $w.top.scroll config -command [list $w.top.list yview]
953 listbox $w.top.list -font fixed -geometry 60x14
954 pack $w.top.list -side left -fill both -expand yes
957 bottom-buttons $w [list {Close} [list destroy $w] \
958 {Up} [list scan-up $attr] \
959 {Down} [list scan-down $attr]] 0
960 bind $w.top.list <Up> [list scan-up $attr]
961 bind $w.top.list <Down> [list scan-down $attr]
963 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
964 wm title $w "Scan $title"
966 z39 callback [list scan-response $attr 0 35]
967 z39.scan numberOfTermsRequested 5
968 z39.scan preferredPositionInResponse 1
969 z39.scan scan "${attr} 0"
971 show-status {Scanning} 1 0
974 proc scan-term-h {attr} {
982 set nScanTerm [$w.top.entry get]
983 if {$nScanTerm == $scanTerm} {
986 set scanTerm $nScanTerm
987 z39 callback [list scan-response $attr 0 35]
988 z39.scan numberOfTermsRequested 5
989 z39.scan preferredPositionInResponse 1
990 dputs "${attr} \{${scanTerm}\}"
991 if {$scanTerm == ""} {
992 z39.scan scan "${attr} 0"
994 z39.scan scan "${attr} \{${scanTerm}\}"
996 show-status {Scanning} 1 0
999 proc scan-response {attr start toget} {
1005 dputs "In scan-response"
1006 set m [z39.scan numberOfEntriesReturned]
1012 if {![winfo exists .scan-window]} {
1013 show-status {Ready} 0 1
1017 set nScanTerm [$w.top.entry get]
1018 if {$nScanTerm != $scanTerm} {
1019 z39 callback [list scan-response $attr 0 35]
1020 z39.scan numberOfTermsRequested 5
1021 z39.scan preferredPositionInResponse 1
1022 set scanTerm $nScanTerm
1023 dputs "${attr} \{${scanTerm}\}"
1024 if {$scanTerm == ""} {
1025 z39.scan scan "${attr} 0"
1027 z39.scan scan "${attr} \{${scanTerm}\}"
1029 show-status {Scanning} 1 0
1032 set status [z39.scan scanStatus]
1035 show-status {Ready} 0 1
1040 for {set i 0} {$i < $m} {incr i} {
1041 set term [lindex [z39.scan scanLine $i] 1]
1042 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1043 $w.top.list insert $i "$nostr $term"
1046 $w.top.list yview $scanView
1048 $w.top.list delete $start end
1049 for {set i 0} {$i < $m} {incr i} {
1050 set term [lindex [z39.scan scanLine $i] 1]
1051 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1052 $w.top.list insert end "$nostr $term"
1056 show-status {Ready} 0 1
1060 if {$toget > 0 && $m > 1 && $m < $toget} {
1061 set ntoget [expr $toget - $m + 1]
1062 dputs ntoget=$ntoget
1063 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1065 dputs "down continue: $q"
1067 z39.scan numberOfTermsRequested 10
1069 z39.scan numberOfTermsRequested $ntoget
1071 z39.scan preferredPositionInResponse 1
1072 dputs "${attr} \{$q\}"
1073 z39.scan scan "${attr} \{$q\}"
1076 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1077 set ntoget [expr - $toget - $m]
1078 dputs ntoget=$ntoget
1079 z39 callback [list scan-response $attr 0 -$ntoget]
1080 set q [string range [$w.top.list get 0] 8 end]
1081 dputs "up continue: $q"
1083 z39.scan numberOfTermsRequested 10
1084 z39.scan preferredPositionInResponse 11
1086 z39.scan numberOfTermsRequested $ntoget
1087 z39.scan preferredPositionInResponse [incr ntoget]
1089 dputs "${attr} \{$q\}"
1090 z39.scan scan "${attr} \{$q\}"
1093 show-status {Ready} 0 1
1096 proc scan-down {attr} {
1100 set scanView [expr $scanView + 5]
1101 set s [$w.top.list size]
1102 if {$scanView > $s} {
1103 z39 callback [list scan-response $attr [expr $s - 1] 25]
1104 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1106 z39.scan numberOfTermsRequested 10
1107 z39.scan preferredPositionInResponse 1
1108 show-status {Scanning} 1 0
1109 dputs "${attr} \{$q\}"
1110 z39.scan scan "${attr} \{$q\}"
1113 $w.top.list yview $scanView
1116 proc scan-up {attr} {
1120 set scanView [expr $scanView - 5]
1121 if {$scanView < 0} {
1122 z39 callback [list scan-response $attr 0 -25]
1123 set q [string range [$w.top.list get 0] 8 end]
1125 z39.scan numberOfTermsRequested 10
1126 z39.scan preferredPositionInResponse 11
1127 show-status {Scanning} 1 0
1128 z39.scan scan "${attr} \{$q\}"
1131 $w.top.list yview $scanView
1134 proc search-response {} {
1141 dputs "In search-response"
1143 set setMax [z39.$setNo resultCount]
1144 show-message "${setMax} hits"
1145 set l [format "%-4d %7d" $setNo $setMax]
1146 .top.rset.m add command -label $l \
1147 -command [list add-title-lines $setNo 10000 1]
1149 show-status {Ready} 0 1
1150 set status [z39.$setNo responseStatus]
1151 if {[lindex $status 0] == "NSD"} {
1152 set code [lindex $status 1]
1153 set msg [lindex $status 2]
1154 set addinfo [lindex $status 3]
1155 tkerror "NSD$code: $msg: $addinfo"
1163 show-status {Ready} 0 1
1168 z39 callback {present-response}
1169 z39.$setNo present $setOffset 1
1170 show-status {Retrieving} 1 0
1173 proc present-more {number} {
1178 dputs "setOffset=$setOffset"
1179 dputs "present-more"
1181 dputs "setNo=$setNo"
1184 set max [z39.$setNo resultCount]
1185 if {$max <= $setOffset} {
1187 dputs "setOffset=$setOffset"
1190 if {$number == ""} {
1194 if {$setMax > $max} {
1198 z39 callback {present-response}
1200 set toGet [expr $setMax - $setOffset + 1]
1207 z39.$setNo present $setOffset $toGet
1208 show-status {Retrieving} 1 0
1211 proc init-title-lines {} {
1212 .data.record delete 0.0 end
1215 proc title-press {y setno} {
1216 show-full-marc $setno [expr 1 + [.data.list nearest $y]] 0
1219 proc add-title-lines {setno no offset} {
1220 global displayFormats
1221 global displayFormat
1225 set setno $lastSetNo
1227 set lastSetNo $setno
1230 .bot.a.set configure -text $setno
1231 .data.record delete 0.0 end
1233 set ffunc [lindex $displayFormats $displayFormat]
1234 set ffunc "display-$ffunc"
1235 for {set i 0} {$i < $no} {incr i} {
1236 set o [expr $i + $offset]
1237 set type [z39.$setno type $o]
1241 .data.record tag bind r$o <Any-Enter> {}
1242 .data.record tag bind r$o <Any-Leave> {}
1243 set insert0 [.data.record index insert]
1244 $ffunc $setno $o .data.record 1
1245 .data.record tag add r$o $insert0 insert
1246 .data.record tag bind r$o <1> \
1247 [list popup-marc $setno $o 0 0]
1252 proc present-response {} {
1258 dputs "In present-response"
1259 set no [z39.$setNo numberOfRecordsReturned]
1260 dputs "Returned $no records, setOffset $setOffset"
1261 add-title-lines $setNo $no $setOffset
1262 set setOffset [expr $setOffset + $no]
1263 set status [z39.$setNo responseStatus]
1264 if {[lindex $status 0] == "NSD"} {
1265 show-status {Ready} 0 1
1266 set code [lindex $status 1]
1267 set msg [lindex $status 2]
1268 set addinfo [lindex $status 3]
1269 tkerror "NSD$code: $msg: $addinfo"
1273 show-status {Ready} 0 1
1277 if {$no > 0 && $setOffset <= $setMax} {
1278 dputs "present-request from ${setOffset}"
1279 set toGet [expr $setMax - $setOffset + 1]
1283 z39.$setNo present $setOffset $toGet
1285 show-status {Ready} 0 1
1289 proc left-cursor {w} {
1290 set i [$w index insert]
1297 proc right-cursor {w} {
1298 set i [$w index insert]
1303 proc bind-fields {list returnAction escapeAction} {
1304 set max [expr [llength $list]-1]
1305 for {set i 0} {$i < $max} {incr i} {
1306 bind [lindex $list $i] <Return> $returnAction
1307 bind [lindex $list $i] <Escape> $escapeAction
1308 bind [lindex $list $i] <Tab> [list focus [lindex $list [expr $i+1]]]
1309 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1310 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1312 bind [lindex $list $i] <Return> $returnAction
1313 bind [lindex $list $i] <Escape> $escapeAction
1314 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1315 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1316 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1317 focus [lindex $list 0]
1320 proc entry-fields {parent list tlist returnAction escapeAction} {
1323 foreach field $list {
1324 set label ${parent}.${field}.label
1325 set entry ${parent}.${field}.entry
1326 label $label -text [lindex $tlist $i] -anchor e
1327 entry $entry -width 32 -relief sunken
1328 pack $label -side left
1329 pack $entry -side right
1330 lappend alist $entry
1333 bind-fields $alist $returnAction $escapeAction
1336 proc define-target-dialog {} {
1337 set w .target-define
1343 pack $w.top.target \
1344 -side top -anchor e -pady 2
1345 entry-fields $w.top {target} \
1347 {define-target-action} {destroy .target-define}
1348 top-down-ok-cancel $w {define-target-action} 1
1351 proc protocol-setup-delete {target} {
1353 global settingsChanged
1355 set a [alert "Are you sure you want to delete the target \
1356 definition $target ?"]
1358 set wno [lindex $profile($target) 12]
1361 unset profile($target)
1362 set settingsChanged 1
1367 proc protocol-setup-action {target} {
1370 global protocolRadioType
1371 global settingsChanged
1374 global ResultSetCheck
1376 set wno [lindex $profile($target) 12]
1380 set settingsChanged 1
1381 set len [$w.top.databases.list size]
1382 for {set i 0} {$i < $len} {incr i} {
1383 lappend b [$w.top.databases.list get $i]
1385 set profile($target) [list [$w.top.description.entry get] \
1386 [$w.top.host.entry get] \
1387 [$w.top.port.entry get] \
1388 [$w.top.idAuthentication.entry get] \
1389 [$w.top.maximumRecordSize.entry get] \
1390 [$w.top.preferredMessageSize.entry get] \
1396 $protocolRadioType \
1400 dputs $profile($target)
1404 proc place-force {window parent} {
1405 set g [wm geometry $parent]
1407 set p1 [string first + $g]
1408 set p2 [string last + $g]
1410 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1411 set y [expr 60+[string range $g [expr $p2 +1] end]]
1412 wm geometry $window +${x}+${y}
1415 proc add-database-action {target} {
1418 set wno [lindex $profile($target) 12]
1421 $w.top.databases.list insert end \
1422 [.database-select.top.database.entry get]
1423 destroy .database-select
1426 proc add-database {target} {
1429 set w .database-select
1431 set oldFocus [focus]
1434 set wno [lindex $profile($target) 12]
1435 place-force $w .setup-${wno}
1439 frame $w.top.database
1441 pack $w.top.database -side top -anchor e -pady 2
1443 entry-fields $w.top {database} \
1444 {{Database to add:}} \
1445 [list add-database-action $target] {destroy .database-select}
1447 top-down-ok-cancel $w [list add-database-action $target] 1
1451 proc delete-database {target} {
1454 set wno [lindex $profile($target) 12]
1457 foreach i [$w.top.databases.list curselection] {
1458 set b [$w.top.databases.list get $i]
1461 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1463 foreach i [lsort -decreasing \
1464 [$w.top.databases.list curselection]] {
1465 $w.top.databases.list delete $i
1470 proc protocol-setup {target} {
1473 global protocolRadioType
1476 global ResultSetCheck
1478 set wno [lindex $profile($target) 12]
1483 wm title $w "Setup $target"
1487 if {$target == ""} {
1491 dputs $profile($target)
1495 frame $w.top.description
1496 frame $w.top.idAuthentication
1497 frame $w.top.maximumRecordSize
1498 frame $w.top.preferredMessageSize
1499 frame $w.top.cs-type -relief ridge -border 2
1500 frame $w.top.protocol -relief ridge -border 2
1501 frame $w.top.query -relief ridge -border 2
1502 frame $w.top.databases -relief ridge -border 2
1504 # Maximum/preferred/idAuth ...
1505 pack $w.top.description $w.top.host $w.top.port \
1506 $w.top.idAuthentication $w.top.maximumRecordSize \
1507 $w.top.preferredMessageSize -side top -anchor e -pady 2
1509 entry-fields $w.top {description host port idAuthentication \
1510 maximumRecordSize preferredMessageSize} \
1511 {{Description:} {Host:} {Port:} {Id Authentication:} \
1512 {Maximum Record Size:} {Preferred Message Size:}} \
1513 [list protocol-setup-action $target] [list destroy $w]
1515 foreach sub {description host port idAuthentication \
1516 maximumRecordSize preferredMessageSize} {
1518 bind $w.top.$sub.entry <Control-a> [list add-database $target]
1519 bind $w.top.$sub.entry <Control-d> [list delete-database $target]
1521 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1522 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1523 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1524 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1525 $w.top.maximumRecordSize.entry insert 0 [lindex $profile($target) 4]
1526 $w.top.preferredMessageSize.entry insert 0 [lindex $profile($target) 5]
1527 set csRadioType [lindex $profile($target) 6]
1528 set RPNCheck [lindex $profile($target) 8]
1529 set CCLCheck [lindex $profile($target) 9]
1530 set ResultSetCheck [lindex $profile($target) 10]
1531 set protocolRadioType [lindex $profile($target) 11]
1532 if {$protocolRadioType == ""} {
1533 set protocolRadioType Z39
1537 pack $w.top.databases -side left -pady 4 -padx 4 -expand yes -fill both
1539 label $w.top.databases.label -text "Databases"
1540 button $w.top.databases.add -text "Add" \
1541 -command [list add-database $target]
1542 button $w.top.databases.delete -text "Delete" \
1543 -command [list delete-database $target]
1544 listbox $w.top.databases.list -geometry 20x6 \
1545 -yscrollcommand "$w.top.databases.scroll set"
1546 scrollbar $w.top.databases.scroll -orient vertical -border 1
1547 pack $w.top.databases.label -side top -fill x \
1549 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1551 pack $w.top.databases.list -side left -fill both -expand yes \
1553 pack $w.top.databases.scroll -side right -fill y \
1555 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1557 foreach b [lindex $profile($target) 7] {
1558 $w.top.databases.list insert end $b
1562 pack $w.top.cs-type -pady 4 -padx 4 -side top -fill x
1564 label $w.top.cs-type.label -text "Transport"
1565 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1566 -variable csRadioType -value tcpip
1567 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1568 -variable csRadioType -value mosi
1570 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1571 -padx 4 -side top -fill x
1574 pack $w.top.protocol -pady 4 -padx 4 -side top -fill x
1576 label $w.top.protocol.label -text "Protocol"
1577 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1578 -variable protocolRadioType -value Z39
1579 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1580 -variable protocolRadioType -value SR
1582 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1583 -padx 4 -side top -fill x
1586 pack $w.top.query -pady 4 -padx 4 -side top -fill x
1588 label $w.top.query.label -text "Query support"
1589 checkbutton $w.top.query.c1 -text "RPN query" -anchor w -variable RPNCheck
1590 checkbutton $w.top.query.c2 -text "CCL query" -anchor w -variable CCLCheck
1591 checkbutton $w.top.query.c3 -text "Result sets" -anchor w -variable ResultSetCheck
1593 pack $w.top.query.label -side top
1594 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
1595 -padx 4 -side top -fill x
1598 bottom-buttons $w [list {Ok} [list protocol-setup-action $target] \
1599 {Delete} [list protocol-setup-delete $target] \
1600 {Cancel} [list destroy $w]] 0
1603 proc database-select-action {} {
1604 set w .database-select.top
1606 foreach indx [$w.databases.list curselection] {
1607 lappend b [$w.databases.list get $indx]
1610 z39 databaseNames $b
1612 destroy .database-select
1615 proc database-select {} {
1616 set w .database-select
1626 frame $w.top.databases -relief ridge -border 2
1628 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
1630 label $w.top.databases.label -text "List"
1631 listbox $w.top.databases.list -geometry 20x6 \
1632 -yscrollcommand "$w.top.databases.scroll set"
1633 scrollbar $w.top.databases.scroll -orient vertical -border 1
1634 pack $w.top.databases.label -side top -fill x \
1636 pack $w.top.databases.list -side left -fill both -expand yes \
1638 pack $w.top.databases.scroll -side right -fill y \
1640 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1642 foreach b [lindex $profile($hostid) 7] {
1643 $w.top.databases.list insert end $b
1645 top-down-ok-cancel $w {database-select-action} 1
1648 proc cascade-target-list {} {
1651 foreach sub [winfo children .top.target.m.clist] {
1654 .top.target.m.clist delete 0 last
1655 foreach n [array names profile] {
1656 if {$n != "Default"} {
1657 set nl [lindex $profile($n) 12]
1658 if {[llength [lindex $profile($n) 7]] > 1} {
1659 .top.target.m.clist add cascade -label $n \
1660 -menu .top.target.m.clist.$nl
1661 menu .top.target.m.clist.$nl
1662 foreach b [lindex $profile($n) 7] {
1663 .top.target.m.clist.$nl add command -label $b \
1664 -command [list reopen-target $n $b]
1667 .top.target.m.clist add command -label $n \
1668 -command [list reopen-target $n {}]
1672 .top.target.m.slist delete 0 last
1673 foreach n [array names profile] {
1674 if {$n != "Default"} {
1675 .top.target.m.slist add command -label $n \
1676 -command [list protocol-setup $n]
1681 proc query-select {i} {
1682 global queryButtonsFind
1683 global queryInfoFind
1687 set queryInfoFind [lindex $queryInfo $i]
1688 set queryButtonsFind [lindex $queryButtons $i]
1690 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
1693 proc query-new-action {} {
1697 global settingsChanged
1699 set settingsChanged 1
1700 lappend queryTypes [.query-new.top.index.entry get]
1701 lappend queryButtons {}
1702 lappend queryInfo {}
1716 -side top -anchor e -pady 2
1717 entry-fields $w.top index \
1719 query-new-action {destroy .query-new}
1720 top-down-ok-cancel $w query-new-action 1
1723 proc query-delete-action {queryNo} {
1727 global settingsChanged
1729 set settingsChanged 1
1731 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
1732 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
1733 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
1734 destroy .query-delete
1738 proc query-delete {queryNo} {
1746 set n [lindex $queryTypes $queryNo]
1748 label $w.top.warning -bitmap warning
1749 message $w.top.quest -text "Are you sure you want to delete the \
1750 query type $n ?" -aspect 200
1751 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
1752 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
1753 {Cancel} [list destroy $w]] 1
1756 proc cascade-query-list {} {
1758 set w .top.options.m.query
1761 $w.slist delete 0 last
1762 foreach n $queryTypes {
1763 $w.slist add command -label $n -command [list query-setup $i]
1768 $w.clist delete 0 last
1769 foreach n $queryTypes {
1770 $w.clist add command -label $n -command [list query-select $i]
1774 $w.dlist delete 0 last
1775 foreach n $queryTypes {
1776 $w.dlist add command -label $n -command [list query-delete $i]
1781 proc save-geometry {} {
1782 global windowGeometry
1785 global displayFormat
1788 set windowGeometry(.) [wm geometry .]
1790 set f [open "clientg.tcl" w]
1792 puts $f "set hotTargets \{ $hotTargets \}"
1793 puts $f "set textWrap $textWrap"
1794 puts $f "set displayFormat $displayFormat"
1795 puts $f "set popupMarcdf $popupMarcdf"
1796 foreach n [array names windowGeometry] {
1797 puts -nonewline $f "set \{windowGeometry($n)\} \{"
1798 puts -nonewline $f $windowGeometry($n)
1804 proc save-settings {} {
1806 global settingsChanged
1811 set f [open "clientrc.tcl" w]
1812 puts $f "# Setup file"
1814 foreach n [array names profile] {
1815 puts -nonewline $f "set \{profile($n)\} \{"
1816 puts -nonewline $f $profile($n)
1819 puts -nonewline $f "set queryTypes \{"
1820 puts -nonewline $f $queryTypes
1823 puts -nonewline $f "set queryButtons \{"
1824 puts -nonewline $f $queryButtons
1827 puts -nonewline $f "set queryInfo \{"
1828 puts -nonewline $f $queryInfo
1831 set settingsChanged 0
1843 label $w.top.warning -bitmap warning
1844 message $w.top.message -text $ask -aspect 200 \
1845 -font -Adobe-Times-Medium-R-Normal-*-180-*
1847 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
1850 top-down-ok-cancel $w {alert-action} 1
1854 proc alert-action {} {
1860 proc exit-action {} {
1861 global settingsChanged
1863 if {$settingsChanged} {
1864 set a [alert "you haven't saved your settings. Do you wish to save?"]
1873 proc listbuttonaction {w name h user i} {
1874 $w configure -text [lindex $name 0]
1875 $h [lindex $name 1] $user $i
1878 proc listbuttonx {button no names handle user} {
1879 if {[winfo exists $button]} {
1880 $button configure -text [lindex [lindex $names $no] 0]
1881 ${button}.m delete 0 last
1883 menubutton $button -text [lindex [lindex $names $no] 0] \
1884 -width 10 -menu ${button}.m -relief raised -border 1
1888 foreach name $names {
1889 ${button}.m add command -label [lindex $name 0] \
1890 -command [list listbuttonaction ${button} $name \
1896 proc listbutton {button no names} {
1897 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
1898 -relief raised -border 1
1900 foreach name $names {
1901 ${button}.m add command -label $name \
1902 -command [list ${button} configure -text $name]
1906 proc listbuttonv-action {button var names i} {
1909 set $var [lindex $names [expr $i+1]]
1910 $button configure -text [lindex $names $i]
1913 proc listbuttonv {button var names} {
1917 eval "set val $$var"
1918 set l [llength $names]
1919 for {set i 1} {$i < $l} {incr i 2} {
1920 if {$val == [lindex $names $i]} {
1922 set n [lindex $names $i]
1926 if {[winfo exists $button]} {
1927 $button configure -text $n
1930 menubutton $button -text $n -menu ${button}.m \
1931 -relief raised -border 1
1933 for {set i 0} {$i < $l} {incr i 2} {
1934 ${button}.m add command -label [lindex $names $i] \
1935 -command [list listbuttonv-action $button $var $names $i]
1939 proc query-add-index-action {queryNo} {
1943 global queryButtonsTmp
1945 set newI [.query-add-index.top.index.entry get]
1946 lappend queryInfoTmp [list $newI {}]
1947 $w.top.index.list insert end $newI
1948 destroy .query-add-index
1949 #destroy $w.top.lines
1950 #frame $w.top.lines -relief ridge -border 2
1951 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1952 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
1955 proc query-add-line {queryNo} {
1959 global queryButtonsTmp
1961 lappend queryButtonsTmp {I 0}
1963 #destroy $w.top.lines
1964 #frame $w.top.lines -relief ridge -border 2
1965 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1966 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
1969 proc query-del-line {queryNo} {
1973 global queryButtonsTmp
1975 set l [llength $queryButtonsTmp]
1980 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
1981 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1984 proc query-add-index {queryNo} {
1985 set w .query-add-index
1988 place-force $w .query-setup
1992 -side top -anchor e -pady 2
1993 entry-fields $w.top {index} \
1995 [list query-add-index-action $queryNo] [list destroy $w]
1996 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
1999 proc query-setup-action {queryNo} {
2002 global queryButtonsTmp
2004 global queryButtonsFind
2005 global queryInfoFind
2007 global settingsChanged
2009 set settingsChanged 1
2011 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
2013 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
2015 set queryInfoFind $queryInfoTmp
2016 set queryButtonsFind $queryButtonsTmp
2018 destroy .query-setup
2019 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2022 proc activate-e-index {value no i} {
2023 global queryButtonsTmp
2024 global queryIndexTmp
2026 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
2027 dputs $queryButtonsTmp
2028 set queryIndexTmp $i
2031 proc activate-index {value no i} {
2032 global queryButtonsFind
2034 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
2036 dputs "queryButtonsFind $queryButtonsFind"
2039 proc update-attr {} {
2041 listbuttonv $w.top.relation.b relationTmpValue\
2042 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
2043 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
2044 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
2045 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
2046 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
2047 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
2048 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
2049 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
2050 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
2051 {local-number} 107 {string} 108 {numeric string} 109}
2052 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2053 {Left} 2 {Left and right} 3 {No truncation} 100 \
2054 {Process #} 101 {Re-1} 102 {Re-2} 103}
2055 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2056 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2059 proc use-attr {init} {
2071 {BNB card number} 10
2072 {BGF(sic) number} 11
2074 {Dewey classification} 13
2075 {UDC classification} 14
2076 {Bliss classification} 15
2078 {NLM call number} 17
2079 {NAL call number} 18
2080 {MOS call number} 19
2081 {Local classification} 20
2082 {Subject heading} 21
2084 {BDI-index-subject} 23
2088 {LC-subject-heading} 27
2089 {RVM-subject-heading} 28
2090 {Local subject index} 29
2092 {Date of publication} 31
2093 {Date of acquisition} 32
2095 {Title-collective} 34
2098 {Title-added-title-page} 37
2102 {Title-other-variant} 41
2104 {Title-abbreviated} 43
2108 {Subject-subdivision} 47
2109 {Number-natl-bibliography} 48
2110 {Number-legal-deposit} 49
2111 {Number-govt-publication} 50
2112 {Number-publisher-for-music} 51
2114 {Number-local-call} 53
2116 {Code-geographic-area} 55
2117 {Code-institution} 56
2119 {Name-geographic} 58
2120 {Place-publication} 59
2122 {Microform-generation} 61
2129 {Author-name-personal} 1004
2130 {Author-name-corporate} 1005
2131 {Author-name-conference} 1006
2132 {Identifier-standard} 1007
2133 {Subject-LC-children's} 1008
2134 {Subject-name-personal} 1009
2136 {Date/time added to database} 1011
2137 {Date/time last modified} 1012
2138 {Authority/format identifier} 1013
2140 {Concept-reference} 1015
2142 {Server choice} 1017
2144 {Record source} 1019
2147 {Geographic class} 1022
2151 {Related periodical} 1026
2152 {Report number} 1027
2154 {Thematic number} 1030
2155 {Material type} 1031
2163 set l [llength $attr]
2168 for {set i 0} {$i < $l} {incr i} {
2169 $w.top.use.list insert end [lindex $attr $i]
2171 if {$useTmpValue == [lindex $attr $i]} {
2176 $w.top.use.list select from $s
2177 $w.top.use.list select to $s
2182 $w.top.use.list yview $s
2184 set lno [lindex [$w.top.use.list curselection] 0]
2185 set i [expr $lno+$lno+1]
2186 set useTmpValue [lindex $attr $i]
2187 dputs "useTmpValue=$useTmpValue"
2191 proc index-setup-action {oldAttr queryNo indexNo} {
2192 set attr [lindex $oldAttr 0]
2195 global relationTmpValue
2196 global structureTmpValue
2197 global truncationTmpValue
2198 global completenessTmpValue
2199 global positionTmpValue
2204 dputs "index-setup-action"
2205 dputs "queryNo $queryNo"
2206 dputs "indexNo $indexNo"
2207 if {$useTmpValue > 0} {
2208 lappend attr "1=$useTmpValue"
2210 if {$relationTmpValue > 0} {
2211 lappend attr "2=$relationTmpValue"
2213 if {$positionTmpValue > 0} {
2214 lappend attr "3=$positionTmpValue"
2216 if {$structureTmpValue > 0} {
2217 lappend attr "4=$structureTmpValue"
2219 if {$truncationTmpValue > 0} {
2220 lappend attr "5=$truncationTmpValue"
2222 if {$completenessTmpValue > 0} {
2223 lappend attr "6=$completenessTmpValue"
2225 dputs "new attr $attr"
2226 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2227 destroy .index-setup
2230 proc index-setup {attr queryNo indexNo} {
2233 global relationTmpValue
2234 global structureTmpValue
2235 global truncationTmpValue
2236 global completenessTmpValue
2237 global positionTmpValue
2239 set relationTmpValue 0
2240 set truncationTmpValue 0
2241 set structureTmpValue 0
2242 set positionTmpValue 0
2243 set completenessTmpValue 0
2246 set len [llength $attr]
2247 for {set i 1} {$i < $len} {incr i} {
2248 set q [lindex $attr $i]
2249 set l [string first = $q]
2251 set t [string range $q 0 [expr $l - 1]]
2252 set v [string range $q [expr $l + 1] end]
2255 { set useTmpValue $v }
2257 { set relationTmpValue $v }
2259 { set positionTmpValue $v }
2261 { set structureTmpValue $v }
2263 { set truncationTmpValue $v }
2265 { set completenessTmpValue $v }
2269 if {[winfo exists $w]} {
2274 set n [lindex $attr 0]
2275 wm title $w "Index setup $n"
2279 frame $w.top.use -relief ridge -border 2
2280 frame $w.top.relation -relief ridge -border 2
2281 frame $w.top.position -relief ridge -border 2
2282 frame $w.top.structure -relief ridge -border 2
2283 frame $w.top.truncation -relief ridge -border 2
2284 frame $w.top.completeness -relief ridge -border 2
2290 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2292 label $w.top.use.label -text "Use"
2293 listbox $w.top.use.list -geometry 26x10 \
2294 -yscrollcommand "$w.top.use.scroll set"
2295 scrollbar $w.top.use.scroll -orient vertical -border 1
2296 pack $w.top.use.label -side top -fill x \
2298 pack $w.top.use.list -side left -fill both -expand yes \
2300 pack $w.top.use.scroll -side right -fill y \
2302 $w.top.use.scroll config -command "$w.top.use.list yview"
2306 # Relation Attributes
2308 pack $w.top.relation -pady 6 -padx 6 -side top
2309 label $w.top.relation.label -text "Relation" -width 18
2311 pack $w.top.relation.label $w.top.relation.b -fill x
2313 # Position Attributes
2315 pack $w.top.position -pady 6 -padx 6 -side top
2316 label $w.top.position.label -text "Position" -width 18
2318 pack $w.top.position.label $w.top.position.b -fill x
2320 # Structure Attributes
2322 pack $w.top.structure -pady 6 -padx 6 -side top
2323 label $w.top.structure.label -text "Structure" -width 18
2325 pack $w.top.structure.label $w.top.structure.b -fill x
2327 # Truncation Attributes
2329 pack $w.top.truncation -pady 6 -padx 6 -side top
2330 label $w.top.truncation.label -text "Truncation" -width 18
2332 pack $w.top.truncation.label $w.top.truncation.b -fill x
2334 # Completeness Attributes
2336 pack $w.top.completeness -pady 6 -padx 6 -side top
2337 label $w.top.completeness.label -text "Completeness" -width 18
2339 pack $w.top.completeness.label $w.top.completeness.b -fill x
2342 bottom-buttons $w [list \
2343 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2344 {Cancel} [list destroy $w]] 0
2348 proc query-edit-index {queryNo} {
2352 set i [lindex [$w.top.index.list curselection] 0]
2356 set attr [lindex $queryInfoTmp $i]
2357 dputs "Editing no $i $attr"
2358 index-setup $attr $queryNo $i
2361 proc query-delete-index {queryNo} {
2363 global queryButtonsTmp
2366 set i [lindex [$w.top.index.list curselection] 0]
2370 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2371 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2372 $w.top.index.list delete $i
2375 proc query-setup {queryNo} {
2381 global queryButtonsTmp
2383 global queryIndexTmp
2386 set queryName [lindex $queryTypes $queryNo]
2387 set queryInfoTmp [lindex $queryInfo $queryNo]
2388 set queryButtonsTmp [lindex $queryButtons $queryNo]
2393 wm title $w "Query setup $queryName"
2397 frame $w.top.lines -relief ridge -border 2
2399 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2403 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2405 button $w.top.lines.add -text "Add" \
2406 -command [list query-add-line $queryNo]
2407 button $w.top.lines.del -text "Remove" \
2408 -command [list query-del-line $queryNo]
2410 pack $w.top.lines.del -fill x -side bottom
2411 pack $w.top.lines.add -fill x -pady 10 -side bottom
2415 frame $w.top.index -relief ridge -border 2
2416 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2418 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2419 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2420 -command [list $w.top.index.list yview]
2421 bind $w.top.index.list <2> [list query-edit-index $queryNo]
2423 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2424 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2426 $w.top.index.list select from 0
2427 $w.top.index.list select to 0
2429 foreach x $queryInfoTmp {
2430 $w.top.index.list insert end [lindex $x 0]
2433 bottom-buttons $w [list \
2434 {Ok} [list query-setup-action $queryNo] \
2435 {Add index} [list query-add-index $queryNo] \
2436 {Edit index} [list query-edit-index $queryNo] \
2437 {Delete index} [list query-delete-index $queryNo] \
2438 {Cancel} [list destroy $w]] 0
2441 proc index-clear {} {
2442 global queryButtonsFind
2445 foreach b $queryButtonsFind {
2446 .lines.$i.e delete 0 end
2451 proc index-query {} {
2452 global queryButtonsFind
2453 global queryInfoFind
2458 foreach b $queryButtonsFind {
2459 set term [string trim [.lines.$i.e get]]
2461 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
2463 set len [string length $term]
2467 if {[string index $term $len] == "?"} {
2469 set term [string range $term 0 [expr $len - 1]]
2471 if {[string index $term 0] == "?"} {
2473 set term [string range $term 1 end]
2475 set term "\{${term}\}"
2476 if {$right && $left} {
2477 set term "@attr 5=3 ${term}"
2479 set term "@attr 5=1 ${term}"
2481 set term "@attr 5=2 ${term}"
2484 set term "@attr $a ${term}"
2487 set qs "@and ${qs} ${term}"
2498 proc index-focus-in {w i} {
2499 global curIndexEntry
2501 $w.$i configure -background red
2502 set curIndexEntry $i
2505 proc index-lines {w realOp buttonInfo queryInfo handle} {
2507 foreach b $buttonInfo {
2508 if {! [winfo exists $w.$i]} {
2509 frame $w.$i -background white -border 1
2511 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
2514 if {! [winfo exists $w.$i.e]} {
2515 entry $w.$i.e -width 32 -relief sunken -border 1
2516 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
2517 bind $w.$i.e <FocusOut> [list $w.$i configure \
2519 pack $w.$i.l -side left
2520 pack $w.$i.e -side left -fill x -expand yes
2521 pack $w.$i -side top -fill x -padx 2 -pady 2
2522 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2523 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2524 bind $w.$i.e <Return> search-request
2527 pack $w.$i.l -side left
2528 pack $w.$i -side top -fill x -padx 2 -pady 2
2533 while {[winfo exists $w.$j]} {
2544 bind $w.$j.e <Tab> "focus $w.$k.e"
2548 bind $w.$i.e <Tab> "focus $w.0.e"
2553 proc search-fields {w buttondefs} {
2555 foreach buttondef $buttondefs {
2556 frame $w.$i -background white
2558 listbutton $w.$i.l 0 $buttondef
2559 entry $w.$i.e -width 32 -relief sunken
2561 pack $w.$i.l -side left
2562 pack $w.$i.e -side left -fill x -expand yes
2564 pack $w.$i -side top -fill x -padx 2 -pady 2
2566 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2567 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2575 bind $w.$j.e <Tab> "focus $w.$k.e \n
2576 $w.$k configure -background red \n
2577 $w.$j configure -background white"
2580 bind $w.$i.e <Tab> "focus $w.0.e \n
2581 $w.0 configure -background red \n
2582 $w.$i configure -background white"
2584 $w.0 configure -background red
2587 if {[info exists windowGeometry(.)]} {
2588 set g $windowGeometry(.)
2596 frame .top -border 1 -relief raised
2597 frame .lines -border 1 -relief raised
2598 frame .mid -border 1 -relief raised
2599 frame .data -border 1 -relief raised
2600 frame .bot -border 1 -relief raised
2601 pack .top .lines .mid -side top -fill x
2602 pack .data -side top -fill both -expand yes
2605 menubutton .top.file -text "File" -menu .top.file.m
2607 .top.file.m add command -label "Save settings" -command {save-settings}
2608 .top.file.m add separator
2609 .top.file.m add command -label "Exit" -command {exit-action}
2611 menubutton .top.target -text "Target" -menu .top.target.m
2613 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
2614 .top.target.m add command -label "Disconnect" -command {close-target}
2615 .top.target.m add command -label "About" -command {about-target}
2616 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
2617 .top.target.m add command -label "Setup new" -command {define-target-dialog}
2618 .top.target.m add separator
2621 .top.target.m disable 1
2622 .top.target.m disable 2
2624 menu .top.target.m.clist
2625 menu .top.target.m.slist
2628 menubutton .top.service -text "Service" -menu .top.service.m
2630 .top.service.m add command -label "Database" -command {database-select}
2631 .top.service.m add cascade -label "Present" -menu .top.service.m.present
2632 menu .top.service.m.present
2633 .top.service.m.present add command -label "10 More" \
2634 -command [list present-more 10]
2635 .top.service.m.present add command -label "All" \
2636 -command [list present-more {}]
2637 .top.service.m add command -label "Search" -command {search-request}
2638 .top.service.m add command -label "Scan" -command {scan-request}
2640 .top.service configure -state disabled
2642 menubutton .top.rset -text "Set" -menu .top.rset.m
2644 .top.rset.m add command -label "Load" -command {load-set}
2645 .top.rset.m add separator
2647 menubutton .top.options -text "Options" -menu .top.options.m
2649 .top.options.m add cascade -label "Query" -menu .top.options.m.query
2650 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
2651 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
2653 menu .top.options.m.query
2654 .top.options.m.query add cascade -label "Select" \
2655 -menu .top.options.m.query.clist
2656 .top.options.m.query add cascade -label "Edit" \
2657 -menu .top.options.m.query.slist
2658 .top.options.m.query add command -label "New" \
2659 -command {query-new}
2660 .top.options.m.query add cascade -label "Delete" \
2661 -menu .top.options.m.query.dlist
2663 menu .top.options.m.query.slist
2664 menu .top.options.m.query.clist
2665 menu .top.options.m.query.dlist
2668 menu .top.options.m.formats
2670 foreach f $displayFormats {
2671 .top.options.m.formats add radiobutton -label $f -value $i \
2672 -command [list set-display-format $i] -variable displayFormat
2676 menu .top.options.m.wrap
2677 .top.options.m.wrap add radiobutton -label "Character" \
2678 -value char -variable textWrap -command {set-wrap char}
2679 .top.options.m.wrap add radiobutton -label "Word" \
2680 -value word -variable textWrap -command {set-wrap word}
2681 .top.options.m.wrap add radiobutton -label "None" \
2682 -value none -variable textWrap -command {set-wrap none}
2684 menubutton .top.help -text "Help" -menu .top.help.m
2687 .top.help.m add command -label "Help on help" \
2688 -command {tkerror "Help on help not available. Sorry"}
2689 .top.help.m add command -label "About" -command {about-origin}
2691 pack .top.file .top.target .top.service .top.rset .top.options -side left
2692 pack .top.help -side right
2694 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
2696 button .mid.search -width 7 -text {Search} -command search-request \
2698 button .mid.scan -width 7 -text {Scan} \
2699 -command scan-request -state disabled
2700 button .mid.present -width 7 -text {Present} -command [list present-more 10] \
2703 button .mid.clear -width 7 -text {Clear} -command index-clear
2704 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
2705 -fill y -padx 5 -pady 3
2707 text .data.record -height 2 -width 20 -wrap none \
2708 -yscrollcommand [list .data.scroll set] -wrap $textWrap
2709 scrollbar .data.scroll -command [list .data.record yview]
2710 pack .data.scroll -side right -fill y
2711 pack .data.record -expand yes -fill both
2714 if {[tk colormodel .] == "color"} {
2715 .data.record tag configure marc-tag -foreground blue
2716 .data.record tag configure marc-id -foreground red
2718 .data.record tag configure marc-tag -foreground black
2719 .data.record tag configure marc-id -foreground black
2721 .data.record tag configure marc-data -foreground black
2723 button .bot.logo -bitmap @book1 -command cancel-operation
2725 pack .bot.a -side left -fill x
2726 pack .bot.logo -side right -padx 2 -pady 2
2728 message .bot.a.target -text "" -aspect 1000 -border 1
2730 label .bot.a.status -text "Not connected" -width 15 -relief \
2731 sunken -anchor w -border 1
2732 label .bot.a.set -text "" -width 5 -relief \
2733 sunken -anchor w -border 1
2734 label .bot.a.message -text "" -width 15 -relief \
2735 sunken -anchor w -border 1
2737 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
2738 pack .bot.a.status .bot.a.set .bot.a.message \
2739 -side left -padx 2 -pady 2