1 # IR toolkit for tcl/tk
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
7 # Revision 1.47 1995-06-19 14:05:29 adam
8 # Bug fix: asked for SUTRS.
10 # Revision 1.46 1995/06/19 13:06:06 adam
11 # New define: IR_TCL_VERSION.
13 # Revision 1.45 1995/06/19 08:08:44 adam
14 # client.tcl: hotTargets now contain both database and target name.
15 # ir-tcl.c: setting protocol edited. Errors in callbacks are logged
16 # by logf(LOG_WARN, ...) calls.
18 # Revision 1.44 1995/06/16 14:55:18 adam
21 # Revision 1.43 1995/06/16 14:41:05 adam
22 # Scan line entries can be copied to a search entry.
24 # Revision 1.42 1995/06/16 12:28:13 adam
25 # Implemented preferredRecordSyntax.
26 # Minor changes in diagnostic handling.
27 # Record list deleted when connection closes.
29 # Revision 1.41 1995/06/14 15:07:59 adam
30 # Bug fix in cascade-target-list. Uses yaz-version.h.
32 # Revision 1.40 1995/06/14 13:37:17 adam
33 # Setting recordType implemented.
34 # Setting implementationVersion implemented.
35 # Settings implementationId / implementationName edited.
37 # Revision 1.39 1995/06/14 12:16:22 adam
38 # hotTargets, textWrap and displayFormat saved in clientg.tcl.
40 # Revision 1.38 1995/06/14 07:22:45 adam
41 # Target definitions can be deleted.
42 # Listbox used in the query definition dialog.
44 # Revision 1.37 1995/06/13 14:37:59 adam
45 # Work on query setup.
46 # Better about origin/target.
47 # Better presentation formats.
49 # Revision 1.36 1995/06/13 07:42:14 adam
50 # Bindings removed from text widgets.
52 # Revision 1.35 1995/06/12 15:17:31 adam
53 # Text widget used in main window (instead of listbox) to support
54 # better presentation formats.
56 # Revision 1.34 1995/06/12 07:59:07 adam
57 # More work on geometry handling.
59 # Revision 1.33 1995/06/09 11:17:35 adam
60 # Start work on geometry management.
62 # Revision 1.32 1995/06/07 09:16:37 adam
63 # New presentation format.
65 # Revision 1.31 1995/06/06 16:31:09 adam
66 # Bug fix: target names couldn't contain blanks.
69 # Revision 1.30 1995/06/06 11:35:41 adam
70 # Work on scan. Display of old sets.
72 # Revision 1.29 1995/06/05 14:11:18 adam
73 # Bug fix in present-more.
75 # Revision 1.28 1995/06/02 14:52:13 adam
76 # Minor changes really.
78 # Revision 1.27 1995/06/02 14:29:42 adam
79 # Work on scan interface - up/down buttons.
81 # Revision 1.26 1995/06/01 16:36:46 adam
82 # About buttons. Minor bug fixes.
84 # Revision 1.25 1995/05/31 13:09:57 adam
85 # Client searches/presents may be interrupted.
86 # New moving book-logo.
88 # Revision 1.24 1995/05/31 08:36:24 adam
89 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
90 # New method: referenceId. More work on scan.
92 # Revision 1.23 1995/05/29 10:33:41 adam
93 # README and rename of startup script.
95 # Revision 1.22 1995/05/26 11:44:09 adam
96 # Bugs fixed. More work on MARC utilities and queries. Test
97 # client is up-to-date again.
99 # Revision 1.21 1995/05/11 15:34:46 adam
100 # Scan request changed a bit. This version works with RLG.
102 # Revision 1.20 1995/04/21 16:31:57 adam
103 # New radiobutton: protocol (z39v2/SR).
105 # Revision 1.19 1995/04/18 16:11:50 adam
106 # First version of graphical Scan. Some work on query-by-form.
108 # Revision 1.18 1995/04/10 10:50:22 adam
109 # Result-set name defaults to suffix of ir-set name.
110 # Started working on scan. Not finished at this point.
112 # Revision 1.17 1995/03/31 09:34:57 adam
113 # Search-button disabled when there is no connection.
115 # Revision 1.16 1995/03/31 08:56:36 adam
116 # New button "Search".
118 # Revision 1.15 1995/03/28 12:45:22 adam
119 # New ir method failback: called on disconnect/protocol error.
120 # New ir set/get method: protocol: SR / Z3950.
121 # Simple popup and disconnect when failback is invoked.
123 # Revision 1.14 1995/03/22 16:07:55 adam
126 # Revision 1.13 1995/03/21 17:27:26 adam
127 # Short-hand keys in setup.
129 # Revision 1.12 1995/03/21 13:41:03 adam
130 # Comstack cs_create not used too often. Non-blocking connect.
132 # Revision 1.11 1995/03/21 10:39:06 adam
133 # Diagnostic error message displayed with tkerror.
135 # Revision 1.10 1995/03/20 15:24:06 adam
136 # Diagnostic records saved on searchResponse.
138 # Revision 1.9 1995/03/17 18:26:16 adam
139 # Non-blocking i/o used now. Database names popup as cascade items.
141 # Revision 1.8 1995/03/17 15:45:00 adam
142 # Improved target/database setup.
144 # Revision 1.7 1995/03/16 17:54:03 adam
145 # Minor changes really.
147 # Revision 1.6 1995/03/15 19:10:20 adam
148 # Database setup in protocol-setup (rather target setup).
150 # Revision 1.5 1995/03/15 13:59:23 adam
153 # Revision 1.4 1995/03/14 17:32:29 adam
154 # Presentation of full Marc record in popup window.
156 # Revision 1.3 1995/03/12 19:31:52 adam
157 # Pattern matching implemented when retrieving MARC records. More
158 # diagnostic functions.
160 # Revision 1.2 1995/03/10 18:00:15 adam
161 # Actual presentation in line-by-line format. RPN query support.
163 # Revision 1.1 1995/03/09 16:15:07 adam
164 # First presentRequest attempts. Hot-target list.
173 set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} Z39}
175 set settingsChanged 0
186 set queryTypes {Simple}
187 set queryButtons { { {I 0} {I 1} {I 2} } }
188 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
189 {Subject {1=21}} {Any {1=1016}} } }
195 proc read-formats {} {
196 global displayFormats
197 set formats [glob -nocomplain formats/*.tcl]
200 set l [expr [string length $f] - 5]
201 lappend displayFormats [string range $f 8 $l]
209 .data.record configure -wrap $m
216 proc set-display-format {f} {
226 .bot.a.status configure -text "Reformatting"
229 add-title-lines 0 10000 1
231 .bot.a.status configure -text "Ready"
235 proc initBindings {} {
238 bind $w <Double-1> {}
239 bind $w <Triple-1> {}
240 bind $w <B1-Motion> {}
242 bind $w <Shift-B1-Motion> {}
244 bind $w <B2-Motion> {}
245 bind $w <Any-KeyPress> {}
247 bind $w <BackSpace> {}
249 bind $w <Control-h> {}
250 bind $w <Control-d> {}
251 bind $w <Control-v> {}
254 bind $w <B1-Motion> {}
255 bind $w <Shift-B1-Motion> {}
260 proc post-menu {wbutton wmenu} {
263 $wmenu post [winfo rootx $wbutton] \
264 [expr [winfo rooty $wbutton]+[winfo height $wbutton]]
269 global windowGeometry
270 set windowGeometry($w) [wm geometry $w]
273 global windowGeometry
276 if {[info exists windowGeometry($w)]} {
277 set g $windowGeometry($w)
282 bind $w <Destroy> [list destroyGW $w]
285 if {[file readable "clientrc.tcl"]} {
286 source "clientrc.tcl"
289 if {[file readable "clientg.tcl"]} {
293 set queryButtonsFind [lindex $queryButtons 0]
294 set queryInfoFind [lindex $queryInfo 0]
296 proc top-down-window {w} {
297 frame $w.top -relief raised -border 1
298 frame $w.bot -relief raised -border 1
300 pack $w.top -side top -fill both -expand yes
301 pack $w.bot -fill both
304 proc top-down-ok-cancel {w ok-action g} {
305 frame $w.bot.left -relief sunken -border 1
306 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 5 -pady 5
307 button $w.bot.left.ok -width 6 -text {Ok} \
308 -command ${ok-action}
309 pack $w.bot.left.ok -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3
310 button $w.bot.cancel -width 6 -text {Cancel} \
311 -command [list destroy $w]
312 pack $w.bot.cancel -side left -expand yes
320 proc bottom-buttons {w buttonList g} {
322 set l [llength $buttonList]
324 frame $w.bot.$i -relief sunken -border 1
325 pack $w.bot.$i -side left -expand yes -padx 5 -pady 5
326 button $w.bot.$i.ok -text [lindex $buttonList $i] \
327 -command [lindex $buttonList [expr $i+1]]
328 pack $w.bot.$i.ok -expand yes -ipadx 3 -ipady 2 -padx 3 -pady 3 -side left
332 button $w.bot.$i -text [lindex $buttonList $i] \
333 -command [lindex $buttonList [expr $i+1]]
334 pack $w.bot.$i -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3 -side left
344 proc cancel-operation {} {
350 show-status Canceling 0 {}
354 proc show-target {target base} {
358 .bot.a.target configure -text ""
362 .bot.a.target configure -text "$target"
364 .bot.a.target configure -text "$target - $base"
368 proc show-logo {v1} {
375 .bot.logo configure -bitmap @book${v1}
376 after 140 [list show-logo $v1]
380 .bot.logo configure -bitmap @book1
389 proc show-status {status b sb} {
397 .bot.a.status configure -text "$status"
399 if {$busy == 0} {set busy 1}
407 .top.service configure -state normal
408 .mid.search configure -state normal
410 .mid.scan configure -state normal
413 .top.service.m disable 1
414 } elseif {$setOffset > 0 && $setOffset <= [z39.$setNo resultCount]} {
415 .top.service.m enable 1
416 .mid.present configure -state normal
418 .top.service.m disable 1
420 if {[winfo exists .scan-window]} {
421 .scan-window.bot.2 configure -state normal
422 .scan-window.bot.4 configure -state normal
426 .top.service configure -state disabled
427 .mid.search configure -state disabled
428 .mid.scan configure -state disabled
429 .mid.present configure -state disabled
431 if {[winfo exists .scan-window]} {
432 .scan-window.bot.2 configure -state disabled
433 .scan-window.bot.4 configure -state disabled
439 proc show-message {msg} {
440 .bot.a.message configure -text "$msg"
443 proc insertWithTags {w text args} {
444 set start [$w index insert]
445 $w insert insert $text
446 foreach tag [$w tag names $start] {
447 $w tag remove $tag $start insert
450 $w tag add $i $start insert
454 proc popup-license {} {
458 wm title $w "License"
464 text $w.top.t -width 80 -height 10 -wrap word \
465 -yscrollcommand [list $w.top.s set]
466 scrollbar $w.top.s -command [list $w.top.t yview]
468 pack $w.top.s -side right -fill y
469 pack $w.top.t -expand yes -fill both
471 set f [open "LICENSE" r]
472 while {[gets $f buf] != -1} {
473 $w.top.t insert end $buf
474 $w.top.t insert end "\n"
477 bottom-buttons $w [list {Close} [list destroy $w]] 1
480 proc about-target {} {
481 set w .about-target-w
486 wm title $w "About target"
489 frame $w.top.a -relief ridge -border 2
490 frame $w.top.p -relief ridge -border 2
492 pack $w.top.a $w.top.p -side top -fill x
494 label $w.top.a.about -text "About"
495 label $w.top.a.irtcl -text $hostid \
496 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
497 pack $w.top.a.about $w.top.a.irtcl -side top
499 set i [z39 targetImplementationName]
500 label $w.top.p.in -text "Implementation name: $i"
501 set i [z39 targetImplementationId]
502 label $w.top.p.ii -text "Implementation id: $i"
503 set i [z39 targetImplementationVersion]
504 label $w.top.p.iv -text "Implementation version: $i"
506 label $w.top.p.op -text "Protocol options: $i"
508 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
510 bottom-buttons $w [list {Close} [list destroy $w]] 1
513 proc about-origin-logo {n} {
514 set w .about-origin-w
515 if {![winfo exists $w]} {
522 $w.top.a.logo configure -bitmap @book$n
523 after 140 [list about-origin-logo $n]
526 proc about-origin {} {
527 set w .about-origin-w
529 if {[winfo exists $w]} {
534 wm title $w "About IrTcl"
538 frame $w.top.a -relief ridge -border 2
539 frame $w.top.p -relief ridge -border 2
541 pack $w.top.a $w.top.p -side top -fill x
543 label $w.top.a.irtcl -text "IrTcl" \
544 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
545 label $w.top.a.logo -bitmap @book1
546 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
548 set i [z39 implementationName]
549 label $w.top.p.in -text "Implementation name: $i"
550 set i [z39 implementationId]
551 label $w.top.p.ii -text "Implementation id: $i"
552 set i [z39 implementationVersion]
553 label $w.top.p.iv -text "Implementation version: $i"
555 pack $w.top.p.in $w.top.p.ii $w.top.p.iv -side top -anchor nw
558 bottom-buttons $w [list {Close} [list destroy $w] \
559 {License} [list popup-license]] 0
562 proc popup-marc {sno no b df} {
564 global displayFormats
567 if {[z39.$sno type $no] != "DB"} {
571 set w .full-marc-$fullMarcSeq
578 if {[winfo exists $w]} {
586 frame $w.top -relief raised -border 1
587 frame $w.bot -relief raised -border 1
589 pack $w.top -side top -fill both -expand yes
590 pack $w.bot -fill both
592 text $w.top.record -width 60 -height 5 -wrap word \
593 -yscrollcommand [list $w.top.s set]
594 scrollbar $w.top.s -command [list $w.top.record yview]
596 if {[tk colormodel .] == "color"} {
597 $w.top.record tag configure marc-tag -foreground blue
598 $w.top.record tag configure marc-id -foreground red
600 $w.top.record tag configure marc-tag -foreground black
601 $w.top.record tag configure marc-id -foreground black
603 $w.top.record tag configure marc-data -foreground black
606 $w.top.record delete 0.0 end
607 set recordType [z39.$sno recordType $no]
608 wm title $w "$recordType record #$no"
610 set ffunc [lindex $displayFormats $df]
611 set ffunc "display-$ffunc"
613 $ffunc $sno $no $w.top.record 0
616 bind $w.top.record <Return> {destroy .full-marc}
618 pack $w.top.s -side right -fill y
619 pack $w.top.record -expand yes -fill both
622 bottom-buttons $w [list \
623 {Close} [list destroy $w]] 0
625 bottom-buttons $w [list \
626 {Close} [list destroy $w] \
627 {Duplicate} [list popup-marc $sno $no 1 0]] 0
628 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m
629 menu $w.bot.formats.m
631 foreach f $displayFormats {
632 $w.bot.formats.m add radiobutton -label $f \
633 -variable popupMarcdf -value $i \
634 -command [list display-$f $sno $no $w.top.record 0]
637 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 \
638 -padx 3 -pady 3 -side left
642 foreach f $displayFormats {
643 $w.bot.formats.m entryconfigure $i \
644 -command [list display-$f $sno $no $w.top.record 0]
650 proc update-target-hotlist {target base} {
653 set len [llength $hotTargets]
655 .top.target.m delete 6 [expr 6+[llength $hotTargets]]
658 foreach e $hotTargets {
659 if {$target == [lindex $e 0] && $base == [lindex $e 1]} {
660 set hotTargets [lreplace $hotTargets $i $i]
665 set hotTargets [linsert $hotTargets 0 [list $target $base]]
669 proc set-target-hotlist {} {
673 foreach e $hotTargets {
674 set target [lindex $e 0]
675 set base [lindex $e 1]
677 .top.target.m add command -label "$i $target" -command \
678 [list reopen-target $target {}]
680 .top.target.m add command -label "$i $target - $base" -command \
681 [list reopen-target $target $base]
690 proc reopen-target {target base} {
692 open-target $target $base
693 update-target-hotlist $target $base
696 proc define-target-action {} {
699 set target [.target-define.top.target.entry get]
703 foreach n [array names profile] {
709 set seq [lindex $profile(Default) 12]
711 set profile($target) $profile(Default)
712 set profile(Default) [lreplace $profile(Default) 12 12 [incr seq]]
714 protocol-setup $target
715 destroy .target-define
718 proc fail-response {target} {
720 tkerror "Target connection closed or protocol error"
723 proc connect-response {target base} {
724 dputs "connect-response"
725 show-target $target $base
729 proc open-target {target base} {
734 z39 comstack [lindex $profile($target) 6]
735 z39 protocol [lindex $profile($target) 11]
736 z39 idAuthentication [lindex $profile($target) 3]
737 z39 maximumRecordSize [lindex $profile($target) 4]
738 z39 preferredMessageSize [lindex $profile($target) 5]
739 dputs "maximumRecordSize="
740 dputs [z39 maximumRecordSize]
741 dputs "preferredMessageSize="
742 dputs [z39 preferredMessageSize]
743 show-status {Connecting} 1 0
745 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
747 z39 databaseNames $base
749 z39 failback [list fail-response $target]
750 z39 callback [list connect-response $target $base]
753 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
756 tkerror $errorMessage
757 show-status Ready 0 {}
760 # z39 options search present scan namedResultSets triggerResourceCtrl
762 .top.target.m disable 0
763 .top.target.m enable 1
764 .top.target.m enable 2
767 proc close-target {} {
774 .bot.a.set configure -text ""
778 show-status {Not connected} 0 0
781 .top.target.m disable 1
782 .top.target.m disable 2
783 .top.target.m enable 0
786 proc load-set-action {} {
790 ir-set z39.$setNo z39
792 set fname [.load-set.top.filename.entry get]
795 show-status {Loading} 1 {}
797 z39.$setNo loadFile $fname
799 set no [z39.$setNo numberOfRecordsReturned]
800 add-title-lines $setNo $no 1
802 set l [format "%-4d %7d" $setNo $no]
803 .top.rset.m add command -label $l \
804 -command [list add-title-lines $setNo 10000 1]
805 show-status {Ready} 0 {}
817 frame $w.top.filename
818 pack $w.top.filename -side top -anchor e -pady 2
820 entry-fields $w.top {filename} \
822 {load-set-action} {destroy .load-set}
824 top-down-ok-cancel $w {load-set-action} 1
828 proc init-request {} {
836 z39 callback {init-response}
837 show-status {Initializing} 1 {}
838 set err [catch {z39 init} errorMessage]
840 tkerror $errorMessage
841 show-status Ready 0 {}
845 proc init-response {} {
853 if {![z39 initResult]} {
854 show-status {Ready} 0 1
855 set u [z39 userInformationField]
857 tkerror "Connection rejected by target: $u"
859 if {[lsearch [z39 options] scan] >= 0} {
864 show-status {Ready} 0 1
868 proc search-request {} {
878 if {$searchEnable == 0} {
881 set query [index-query]
886 ir-set z39.$setNo z39
888 if {[lindex $profile($target) 10] == 1} {
889 z39.$setNo setName $setNo
890 dputs "setName=${setNo}"
892 z39.$setNo setName Default
893 dputs "setName=Default"
895 if {[lindex $profile($target) 8] == 1} {
896 z39.$setNo queryType rpn
898 if {[lindex $profile($target) 9] == 1} {
899 z39.$setNo queryType ccl
901 z39 callback {search-response}
902 z39.$setNo search $query
903 show-status {Searching} 1 0
906 proc scan-copy {y entry} {
908 set no [$w.top.list nearest $y]
910 .lines.$entry.e delete 0 end
911 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
914 proc scan-request {} {
922 global queryButtonsFind
929 set b [lindex $queryButtonsFind $curIndexEntry]
931 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
932 set attr "@attr $a $attr"
934 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
937 if {![winfo exists $w]} {
944 entry $w.top.entry -relief sunken
945 pack $w.top.entry -fill x -padx 4 -pady 2
946 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
948 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
950 scrollbar $w.top.scroll -orient vertical -border 1
951 pack $w.top.list -side left -fill both -expand yes
952 pack $w.top.scroll -side right -fill y
953 $w.top.scroll config -command [list $w.top.list yview]
955 listbox $w.top.list -font fixed -geometry 60x14
956 pack $w.top.list -side left -fill both -expand yes
959 bottom-buttons $w [list {Close} [list destroy $w] \
960 {Up} [list scan-up $attr] \
961 {Down} [list scan-down $attr]] 0
962 bind $w.top.list <Up> [list scan-up $attr]
963 bind $w.top.list <Down> [list scan-down $attr]
965 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
966 wm title $w "Scan $title"
968 z39 callback [list scan-response $attr 0 35]
969 z39.scan numberOfTermsRequested 5
970 z39.scan preferredPositionInResponse 1
971 z39.scan scan "${attr} 0"
973 show-status {Scanning} 1 0
976 proc scan-term-h {attr} {
984 set nScanTerm [$w.top.entry get]
985 if {$nScanTerm == $scanTerm} {
988 set scanTerm $nScanTerm
989 z39 callback [list scan-response $attr 0 35]
990 z39.scan numberOfTermsRequested 5
991 z39.scan preferredPositionInResponse 1
992 dputs "${attr} \{${scanTerm}\}"
993 if {$scanTerm == ""} {
994 z39.scan scan "${attr} 0"
996 z39.scan scan "${attr} \{${scanTerm}\}"
998 show-status {Scanning} 1 0
1001 proc scan-response {attr start toget} {
1007 dputs "In scan-response"
1008 set m [z39.scan numberOfEntriesReturned]
1014 if {![winfo exists .scan-window]} {
1015 show-status {Ready} 0 1
1019 set nScanTerm [$w.top.entry get]
1020 if {$nScanTerm != $scanTerm} {
1021 z39 callback [list scan-response $attr 0 35]
1022 z39.scan numberOfTermsRequested 5
1023 z39.scan preferredPositionInResponse 1
1024 set scanTerm $nScanTerm
1025 dputs "${attr} \{${scanTerm}\}"
1026 if {$scanTerm == ""} {
1027 z39.scan scan "${attr} 0"
1029 z39.scan scan "${attr} \{${scanTerm}\}"
1031 show-status {Scanning} 1 0
1034 set status [z39.scan scanStatus]
1037 show-status {Ready} 0 1
1042 for {set i 0} {$i < $m} {incr i} {
1043 set term [lindex [z39.scan scanLine $i] 1]
1044 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1045 $w.top.list insert $i "$nostr $term"
1048 $w.top.list yview $scanView
1050 $w.top.list delete $start end
1051 for {set i 0} {$i < $m} {incr i} {
1052 set term [lindex [z39.scan scanLine $i] 1]
1053 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1054 $w.top.list insert end "$nostr $term"
1058 show-status {Ready} 0 1
1062 if {$toget > 0 && $m > 1 && $m < $toget} {
1063 set ntoget [expr $toget - $m + 1]
1064 dputs ntoget=$ntoget
1065 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1067 dputs "down continue: $q"
1069 z39.scan numberOfTermsRequested 10
1071 z39.scan numberOfTermsRequested $ntoget
1073 z39.scan preferredPositionInResponse 1
1074 dputs "${attr} \{$q\}"
1075 z39.scan scan "${attr} \{$q\}"
1078 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1079 set ntoget [expr - $toget - $m]
1080 dputs ntoget=$ntoget
1081 z39 callback [list scan-response $attr 0 -$ntoget]
1082 set q [string range [$w.top.list get 0] 8 end]
1083 dputs "up continue: $q"
1085 z39.scan numberOfTermsRequested 10
1086 z39.scan preferredPositionInResponse 11
1088 z39.scan numberOfTermsRequested $ntoget
1089 z39.scan preferredPositionInResponse [incr ntoget]
1091 dputs "${attr} \{$q\}"
1092 z39.scan scan "${attr} \{$q\}"
1095 show-status {Ready} 0 1
1098 proc scan-down {attr} {
1102 set scanView [expr $scanView + 5]
1103 set s [$w.top.list size]
1104 if {$scanView > $s} {
1105 z39 callback [list scan-response $attr [expr $s - 1] 25]
1106 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1108 z39.scan numberOfTermsRequested 10
1109 z39.scan preferredPositionInResponse 1
1110 show-status {Scanning} 1 0
1111 dputs "${attr} \{$q\}"
1112 z39.scan scan "${attr} \{$q\}"
1115 $w.top.list yview $scanView
1118 proc scan-up {attr} {
1122 set scanView [expr $scanView - 5]
1123 if {$scanView < 0} {
1124 z39 callback [list scan-response $attr 0 -25]
1125 set q [string range [$w.top.list get 0] 8 end]
1127 z39.scan numberOfTermsRequested 10
1128 z39.scan preferredPositionInResponse 11
1129 show-status {Scanning} 1 0
1130 z39.scan scan "${attr} \{$q\}"
1133 $w.top.list yview $scanView
1136 proc search-response {} {
1143 dputs "In search-response"
1145 set setMax [z39.$setNo resultCount]
1146 show-message "${setMax} hits"
1147 set l [format "%-4d %7d" $setNo $setMax]
1148 .top.rset.m add command -label $l \
1149 -command [list add-title-lines $setNo 10000 1]
1151 show-status {Ready} 0 1
1152 set status [z39.$setNo responseStatus]
1153 if {[lindex $status 0] == "NSD"} {
1154 set code [lindex $status 1]
1155 set msg [lindex $status 2]
1156 set addinfo [lindex $status 3]
1157 tkerror "NSD$code: $msg: $addinfo"
1165 show-status {Ready} 0 1
1170 z39 callback {present-response}
1171 z39.$setNo present $setOffset 1
1172 show-status {Retrieving} 1 0
1175 proc present-more {number} {
1180 dputs "setOffset=$setOffset"
1181 dputs "present-more"
1183 dputs "setNo=$setNo"
1186 set max [z39.$setNo resultCount]
1187 if {$max <= $setOffset} {
1189 dputs "setOffset=$setOffset"
1192 if {$number == ""} {
1196 if {$setMax > $max} {
1200 z39 callback {present-response}
1202 set toGet [expr $setMax - $setOffset + 1]
1209 z39.$setNo present $setOffset $toGet
1210 show-status {Retrieving} 1 0
1213 proc init-title-lines {} {
1214 .data.record delete 0.0 end
1217 proc title-press {y setno} {
1218 show-full-marc $setno [expr 1 + [.data.list nearest $y]] 0
1221 proc add-title-lines {setno no offset} {
1222 global displayFormats
1223 global displayFormat
1227 set setno $lastSetNo
1229 set lastSetNo $setno
1232 .bot.a.set configure -text $setno
1233 .data.record delete 0.0 end
1235 set ffunc [lindex $displayFormats $displayFormat]
1236 set ffunc "display-$ffunc"
1237 for {set i 0} {$i < $no} {incr i} {
1238 set o [expr $i + $offset]
1239 set type [z39.$setno type $o]
1243 .data.record tag bind r$o <Any-Enter> {}
1244 .data.record tag bind r$o <Any-Leave> {}
1245 set insert0 [.data.record index insert]
1246 $ffunc $setno $o .data.record 1
1247 .data.record tag add r$o $insert0 insert
1248 .data.record tag bind r$o <1> \
1249 [list popup-marc $setno $o 0 0]
1254 proc present-response {} {
1260 dputs "In present-response"
1261 set no [z39.$setNo numberOfRecordsReturned]
1262 dputs "Returned $no records, setOffset $setOffset"
1263 add-title-lines $setNo $no $setOffset
1264 set setOffset [expr $setOffset + $no]
1265 set status [z39.$setNo responseStatus]
1266 if {[lindex $status 0] == "NSD"} {
1267 show-status {Ready} 0 1
1268 set code [lindex $status 1]
1269 set msg [lindex $status 2]
1270 set addinfo [lindex $status 3]
1271 tkerror "NSD$code: $msg: $addinfo"
1275 show-status {Ready} 0 1
1279 if {$no > 0 && $setOffset <= $setMax} {
1280 dputs "present-request from ${setOffset}"
1281 set toGet [expr $setMax - $setOffset + 1]
1285 z39.$setNo present $setOffset $toGet
1287 show-status {Ready} 0 1
1291 proc left-cursor {w} {
1292 set i [$w index insert]
1299 proc right-cursor {w} {
1300 set i [$w index insert]
1305 proc bind-fields {list returnAction escapeAction} {
1306 set max [expr [llength $list]-1]
1307 for {set i 0} {$i < $max} {incr i} {
1308 bind [lindex $list $i] <Return> $returnAction
1309 bind [lindex $list $i] <Escape> $escapeAction
1310 bind [lindex $list $i] <Tab> [list focus [lindex $list [expr $i+1]]]
1311 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1312 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1314 bind [lindex $list $i] <Return> $returnAction
1315 bind [lindex $list $i] <Escape> $escapeAction
1316 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1317 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1318 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1319 focus [lindex $list 0]
1322 proc entry-fields {parent list tlist returnAction escapeAction} {
1325 foreach field $list {
1326 set label ${parent}.${field}.label
1327 set entry ${parent}.${field}.entry
1328 label $label -text [lindex $tlist $i] -anchor e
1329 entry $entry -width 32 -relief sunken
1330 pack $label -side left
1331 pack $entry -side right
1332 lappend alist $entry
1335 bind-fields $alist $returnAction $escapeAction
1338 proc define-target-dialog {} {
1339 set w .target-define
1345 pack $w.top.target \
1346 -side top -anchor e -pady 2
1347 entry-fields $w.top {target} \
1349 {define-target-action} {destroy .target-define}
1350 top-down-ok-cancel $w {define-target-action} 1
1353 proc protocol-setup-delete {target} {
1355 global settingsChanged
1357 set a [alert "Are you sure you want to delete the target \
1358 definition $target ?"]
1360 set wno [lindex $profile($target) 12]
1363 unset profile($target)
1364 set settingsChanged 1
1369 proc protocol-setup-action {target} {
1372 global protocolRadioType
1373 global settingsChanged
1376 global ResultSetCheck
1378 set wno [lindex $profile($target) 12]
1382 set settingsChanged 1
1383 set len [$w.top.databases.list size]
1384 for {set i 0} {$i < $len} {incr i} {
1385 lappend b [$w.top.databases.list get $i]
1387 set profile($target) [list [$w.top.description.entry get] \
1388 [$w.top.host.entry get] \
1389 [$w.top.port.entry get] \
1390 [$w.top.idAuthentication.entry get] \
1391 [$w.top.maximumRecordSize.entry get] \
1392 [$w.top.preferredMessageSize.entry get] \
1398 $protocolRadioType \
1402 dputs $profile($target)
1406 proc place-force {window parent} {
1407 set g [wm geometry $parent]
1409 set p1 [string first + $g]
1410 set p2 [string last + $g]
1412 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1413 set y [expr 60+[string range $g [expr $p2 +1] end]]
1414 wm geometry $window +${x}+${y}
1417 proc add-database-action {target} {
1420 set wno [lindex $profile($target) 12]
1423 $w.top.databases.list insert end \
1424 [.database-select.top.database.entry get]
1425 destroy .database-select
1428 proc add-database {target} {
1431 set w .database-select
1433 set oldFocus [focus]
1436 set wno [lindex $profile($target) 12]
1437 place-force $w .setup-${wno}
1441 frame $w.top.database
1443 pack $w.top.database -side top -anchor e -pady 2
1445 entry-fields $w.top {database} \
1446 {{Database to add:}} \
1447 [list add-database-action $target] {destroy .database-select}
1449 top-down-ok-cancel $w [list add-database-action $target] 1
1453 proc delete-database {target} {
1456 set wno [lindex $profile($target) 12]
1459 foreach i [$w.top.databases.list curselection] {
1460 set b [$w.top.databases.list get $i]
1463 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1465 foreach i [lsort -decreasing \
1466 [$w.top.databases.list curselection]] {
1467 $w.top.databases.list delete $i
1472 proc protocol-setup {target} {
1475 global protocolRadioType
1478 global ResultSetCheck
1480 set wno [lindex $profile($target) 12]
1485 wm title $w "Setup $target"
1489 if {$target == ""} {
1493 dputs $profile($target)
1497 frame $w.top.description
1498 frame $w.top.idAuthentication
1499 frame $w.top.maximumRecordSize
1500 frame $w.top.preferredMessageSize
1501 frame $w.top.cs-type -relief ridge -border 2
1502 frame $w.top.protocol -relief ridge -border 2
1503 frame $w.top.query -relief ridge -border 2
1504 frame $w.top.databases -relief ridge -border 2
1506 # Maximum/preferred/idAuth ...
1507 pack $w.top.description $w.top.host $w.top.port \
1508 $w.top.idAuthentication $w.top.maximumRecordSize \
1509 $w.top.preferredMessageSize -side top -anchor e -pady 2
1511 entry-fields $w.top {description host port idAuthentication \
1512 maximumRecordSize preferredMessageSize} \
1513 {{Description:} {Host:} {Port:} {Id Authentication:} \
1514 {Maximum Record Size:} {Preferred Message Size:}} \
1515 [list protocol-setup-action $target] [list destroy $w]
1517 foreach sub {description host port idAuthentication \
1518 maximumRecordSize preferredMessageSize} {
1520 bind $w.top.$sub.entry <Control-a> [list add-database $target]
1521 bind $w.top.$sub.entry <Control-d> [list delete-database $target]
1523 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1524 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1525 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1526 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1527 $w.top.maximumRecordSize.entry insert 0 [lindex $profile($target) 4]
1528 $w.top.preferredMessageSize.entry insert 0 [lindex $profile($target) 5]
1529 set csRadioType [lindex $profile($target) 6]
1530 set RPNCheck [lindex $profile($target) 8]
1531 set CCLCheck [lindex $profile($target) 9]
1532 set ResultSetCheck [lindex $profile($target) 10]
1533 set protocolRadioType [lindex $profile($target) 11]
1534 if {$protocolRadioType == ""} {
1535 set protocolRadioType Z39
1539 pack $w.top.databases -side left -pady 4 -padx 4 -expand yes -fill both
1541 label $w.top.databases.label -text "Databases"
1542 button $w.top.databases.add -text "Add" \
1543 -command [list add-database $target]
1544 button $w.top.databases.delete -text "Delete" \
1545 -command [list delete-database $target]
1546 listbox $w.top.databases.list -geometry 20x6 \
1547 -yscrollcommand "$w.top.databases.scroll set"
1548 scrollbar $w.top.databases.scroll -orient vertical -border 1
1549 pack $w.top.databases.label -side top -fill x \
1551 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1553 pack $w.top.databases.list -side left -fill both -expand yes \
1555 pack $w.top.databases.scroll -side right -fill y \
1557 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1559 foreach b [lindex $profile($target) 7] {
1560 $w.top.databases.list insert end $b
1564 pack $w.top.cs-type -pady 4 -padx 4 -side top -fill x
1566 label $w.top.cs-type.label -text "Transport"
1567 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1568 -variable csRadioType -value tcpip
1569 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1570 -variable csRadioType -value mosi
1572 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1573 -padx 4 -side top -fill x
1576 pack $w.top.protocol -pady 4 -padx 4 -side top -fill x
1578 label $w.top.protocol.label -text "Protocol"
1579 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1580 -variable protocolRadioType -value Z39
1581 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1582 -variable protocolRadioType -value SR
1584 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1585 -padx 4 -side top -fill x
1588 pack $w.top.query -pady 4 -padx 4 -side top -fill x
1590 label $w.top.query.label -text "Query support"
1591 checkbutton $w.top.query.c1 -text "RPN query" -anchor w -variable RPNCheck
1592 checkbutton $w.top.query.c2 -text "CCL query" -anchor w -variable CCLCheck
1593 checkbutton $w.top.query.c3 -text "Result sets" -anchor w -variable ResultSetCheck
1595 pack $w.top.query.label -side top
1596 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
1597 -padx 4 -side top -fill x
1600 bottom-buttons $w [list {Ok} [list protocol-setup-action $target] \
1601 {Delete} [list protocol-setup-delete $target] \
1602 {Cancel} [list destroy $w]] 0
1605 proc database-select-action {} {
1606 set w .database-select.top
1608 foreach indx [$w.databases.list curselection] {
1609 lappend b [$w.databases.list get $indx]
1612 z39 databaseNames $b
1614 destroy .database-select
1617 proc database-select {} {
1618 set w .database-select
1628 frame $w.top.databases -relief ridge -border 2
1630 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
1632 label $w.top.databases.label -text "List"
1633 listbox $w.top.databases.list -geometry 20x6 \
1634 -yscrollcommand "$w.top.databases.scroll set"
1635 scrollbar $w.top.databases.scroll -orient vertical -border 1
1636 pack $w.top.databases.label -side top -fill x \
1638 pack $w.top.databases.list -side left -fill both -expand yes \
1640 pack $w.top.databases.scroll -side right -fill y \
1642 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1644 foreach b [lindex $profile($hostid) 7] {
1645 $w.top.databases.list insert end $b
1647 top-down-ok-cancel $w {database-select-action} 1
1650 proc cascade-target-list {} {
1653 foreach sub [winfo children .top.target.m.clist] {
1656 .top.target.m.clist delete 0 last
1657 foreach n [array names profile] {
1658 if {$n != "Default"} {
1659 set nl [lindex $profile($n) 12]
1660 if {[llength [lindex $profile($n) 7]] > 1} {
1661 .top.target.m.clist add cascade -label $n \
1662 -menu .top.target.m.clist.$nl
1663 menu .top.target.m.clist.$nl
1664 foreach b [lindex $profile($n) 7] {
1665 .top.target.m.clist.$nl add command -label $b \
1666 -command [list reopen-target $n $b]
1669 .top.target.m.clist add command -label $n \
1670 -command [list reopen-target $n {}]
1674 .top.target.m.slist delete 0 last
1675 foreach n [array names profile] {
1676 if {$n != "Default"} {
1677 .top.target.m.slist add command -label $n \
1678 -command [list protocol-setup $n]
1683 proc query-select {i} {
1684 global queryButtonsFind
1685 global queryInfoFind
1689 set queryInfoFind [lindex $queryInfo $i]
1690 set queryButtonsFind [lindex $queryButtons $i]
1692 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
1695 proc query-new-action {} {
1699 global settingsChanged
1701 set settingsChanged 1
1702 lappend queryTypes [.query-new.top.index.entry get]
1703 lappend queryButtons {}
1704 lappend queryInfo {}
1718 -side top -anchor e -pady 2
1719 entry-fields $w.top index \
1721 query-new-action {destroy .query-new}
1722 top-down-ok-cancel $w query-new-action 1
1725 proc query-delete-action {queryNo} {
1729 global settingsChanged
1731 set settingsChanged 1
1733 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
1734 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
1735 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
1736 destroy .query-delete
1740 proc query-delete {queryNo} {
1748 set n [lindex $queryTypes $queryNo]
1750 label $w.top.warning -bitmap warning
1751 message $w.top.quest -text "Are you sure you want to delete the \
1752 query type $n ?" -aspect 200
1753 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
1754 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
1755 {Cancel} [list destroy $w]] 1
1758 proc cascade-query-list {} {
1760 set w .top.options.m.query
1763 $w.slist delete 0 last
1764 foreach n $queryTypes {
1765 $w.slist add command -label $n -command [list query-setup $i]
1770 $w.clist delete 0 last
1771 foreach n $queryTypes {
1772 $w.clist add command -label $n -command [list query-select $i]
1776 $w.dlist delete 0 last
1777 foreach n $queryTypes {
1778 $w.dlist add command -label $n -command [list query-delete $i]
1783 proc save-geometry {} {
1784 global windowGeometry
1787 global displayFormat
1790 set windowGeometry(.) [wm geometry .]
1792 set f [open "clientg.tcl" w]
1794 puts $f "set hotTargets \{ $hotTargets \}"
1795 puts $f "set textWrap $textWrap"
1796 puts $f "set displayFormat $displayFormat"
1797 puts $f "set popupMarcdf $popupMarcdf"
1798 foreach n [array names windowGeometry] {
1799 puts -nonewline $f "set \{windowGeometry($n)\} \{"
1800 puts -nonewline $f $windowGeometry($n)
1806 proc save-settings {} {
1808 global settingsChanged
1813 set f [open "clientrc.tcl" w]
1814 puts $f "# Setup file"
1816 foreach n [array names profile] {
1817 puts -nonewline $f "set \{profile($n)\} \{"
1818 puts -nonewline $f $profile($n)
1821 puts -nonewline $f "set queryTypes \{"
1822 puts -nonewline $f $queryTypes
1825 puts -nonewline $f "set queryButtons \{"
1826 puts -nonewline $f $queryButtons
1829 puts -nonewline $f "set queryInfo \{"
1830 puts -nonewline $f $queryInfo
1833 set settingsChanged 0
1845 label $w.top.warning -bitmap warning
1846 message $w.top.message -text $ask -aspect 200 \
1847 -font -Adobe-Times-Medium-R-Normal-*-180-*
1849 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
1852 top-down-ok-cancel $w {alert-action} 1
1856 proc alert-action {} {
1862 proc exit-action {} {
1863 global settingsChanged
1865 if {$settingsChanged} {
1866 set a [alert "you haven't saved your settings. Do you wish to save?"]
1875 proc listbuttonaction {w name h user i} {
1876 $w configure -text [lindex $name 0]
1877 $h [lindex $name 1] $user $i
1880 proc listbuttonx {button no names handle user} {
1881 if {[winfo exists $button]} {
1882 $button configure -text [lindex [lindex $names $no] 0]
1883 ${button}.m delete 0 last
1885 menubutton $button -text [lindex [lindex $names $no] 0] \
1886 -width 10 -menu ${button}.m -relief raised -border 1
1890 foreach name $names {
1891 ${button}.m add command -label [lindex $name 0] \
1892 -command [list listbuttonaction ${button} $name \
1898 proc listbutton {button no names} {
1899 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
1900 -relief raised -border 1
1902 foreach name $names {
1903 ${button}.m add command -label $name \
1904 -command [list ${button} configure -text $name]
1908 proc listbuttonv-action {button var names i} {
1911 set $var [lindex $names [expr $i+1]]
1912 $button configure -text [lindex $names $i]
1915 proc listbuttonv {button var names} {
1919 eval "set val $$var"
1920 set l [llength $names]
1921 for {set i 1} {$i < $l} {incr i 2} {
1922 if {$val == [lindex $names $i]} {
1924 set n [lindex $names $i]
1928 if {[winfo exists $button]} {
1929 $button configure -text $n
1932 menubutton $button -text $n -menu ${button}.m \
1933 -relief raised -border 1
1935 for {set i 0} {$i < $l} {incr i 2} {
1936 ${button}.m add command -label [lindex $names $i] \
1937 -command [list listbuttonv-action $button $var $names $i]
1941 proc query-add-index-action {queryNo} {
1945 global queryButtonsTmp
1947 set newI [.query-add-index.top.index.entry get]
1948 lappend queryInfoTmp [list $newI {}]
1949 $w.top.index.list insert end $newI
1950 destroy .query-add-index
1951 #destroy $w.top.lines
1952 #frame $w.top.lines -relief ridge -border 2
1953 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1954 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
1957 proc query-add-line {queryNo} {
1961 global queryButtonsTmp
1963 lappend queryButtonsTmp {I 0}
1965 #destroy $w.top.lines
1966 #frame $w.top.lines -relief ridge -border 2
1967 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1968 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
1971 proc query-del-line {queryNo} {
1975 global queryButtonsTmp
1977 set l [llength $queryButtonsTmp]
1982 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
1983 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1986 proc query-add-index {queryNo} {
1987 set w .query-add-index
1990 place-force $w .query-setup
1994 -side top -anchor e -pady 2
1995 entry-fields $w.top {index} \
1997 [list query-add-index-action $queryNo] [list destroy $w]
1998 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
2001 proc query-setup-action {queryNo} {
2004 global queryButtonsTmp
2006 global queryButtonsFind
2007 global queryInfoFind
2009 global settingsChanged
2011 set settingsChanged 1
2013 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
2015 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
2017 set queryInfoFind $queryInfoTmp
2018 set queryButtonsFind $queryButtonsTmp
2020 destroy .query-setup
2021 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
2024 proc activate-e-index {value no i} {
2025 global queryButtonsTmp
2026 global queryIndexTmp
2028 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
2029 dputs $queryButtonsTmp
2030 set queryIndexTmp $i
2033 proc activate-index {value no i} {
2034 global queryButtonsFind
2036 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
2038 dputs "queryButtonsFind $queryButtonsFind"
2041 proc update-attr {} {
2043 listbuttonv $w.top.relation.b relationTmpValue\
2044 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
2045 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
2046 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
2047 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
2048 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
2049 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
2050 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
2051 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
2052 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
2053 {local-number} 107 {string} 108 {numeric string} 109}
2054 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2055 {Left} 2 {Left and right} 3 {No truncation} 100 \
2056 {Process #} 101 {Re-1} 102 {Re-2} 103}
2057 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2058 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2061 proc use-attr {init} {
2073 {BNB card number} 10
2074 {BGF(sic) number} 11
2076 {Dewey classification} 13
2077 {UDC classification} 14
2078 {Bliss classification} 15
2080 {NLM call number} 17
2081 {NAL call number} 18
2082 {MOS call number} 19
2083 {Local classification} 20
2084 {Subject heading} 21
2086 {BDI-index-subject} 23
2090 {LC-subject-heading} 27
2091 {RVM-subject-heading} 28
2092 {Local subject index} 29
2094 {Date of publication} 31
2095 {Date of acquisition} 32
2097 {Title-collective} 34
2100 {Title-added-title-page} 37
2104 {Title-other-variant} 41
2106 {Title-abbreviated} 43
2110 {Subject-subdivision} 47
2111 {Number-natl-bibliography} 48
2112 {Number-legal-deposit} 49
2113 {Number-govt-publication} 50
2114 {Number-publisher-for-music} 51
2116 {Number-local-call} 53
2118 {Code-geographic-area} 55
2119 {Code-institution} 56
2121 {Name-geographic} 58
2122 {Place-publication} 59
2124 {Microform-generation} 61
2131 {Author-name-personal} 1004
2132 {Author-name-corporate} 1005
2133 {Author-name-conference} 1006
2134 {Identifier-standard} 1007
2135 {Subject-LC-children's} 1008
2136 {Subject-name-personal} 1009
2138 {Date/time added to database} 1011
2139 {Date/time last modified} 1012
2140 {Authority/format identifier} 1013
2142 {Concept-reference} 1015
2144 {Server choice} 1017
2146 {Record source} 1019
2149 {Geographic class} 1022
2153 {Related periodical} 1026
2154 {Report number} 1027
2156 {Thematic number} 1030
2157 {Material type} 1031
2165 set l [llength $attr]
2170 for {set i 0} {$i < $l} {incr i} {
2171 $w.top.use.list insert end [lindex $attr $i]
2173 if {$useTmpValue == [lindex $attr $i]} {
2178 $w.top.use.list select from $s
2179 $w.top.use.list select to $s
2184 $w.top.use.list yview $s
2186 set lno [lindex [$w.top.use.list curselection] 0]
2187 set i [expr $lno+$lno+1]
2188 set useTmpValue [lindex $attr $i]
2189 dputs "useTmpValue=$useTmpValue"
2193 proc index-setup-action {oldAttr queryNo indexNo} {
2194 set attr [lindex $oldAttr 0]
2197 global relationTmpValue
2198 global structureTmpValue
2199 global truncationTmpValue
2200 global completenessTmpValue
2201 global positionTmpValue
2206 dputs "index-setup-action"
2207 dputs "queryNo $queryNo"
2208 dputs "indexNo $indexNo"
2209 if {$useTmpValue > 0} {
2210 lappend attr "1=$useTmpValue"
2212 if {$relationTmpValue > 0} {
2213 lappend attr "2=$relationTmpValue"
2215 if {$positionTmpValue > 0} {
2216 lappend attr "3=$positionTmpValue"
2218 if {$structureTmpValue > 0} {
2219 lappend attr "4=$structureTmpValue"
2221 if {$truncationTmpValue > 0} {
2222 lappend attr "5=$truncationTmpValue"
2224 if {$completenessTmpValue > 0} {
2225 lappend attr "6=$completenessTmpValue"
2227 dputs "new attr $attr"
2228 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2229 destroy .index-setup
2232 proc index-setup {attr queryNo indexNo} {
2235 global relationTmpValue
2236 global structureTmpValue
2237 global truncationTmpValue
2238 global completenessTmpValue
2239 global positionTmpValue
2241 set relationTmpValue 0
2242 set truncationTmpValue 0
2243 set structureTmpValue 0
2244 set positionTmpValue 0
2245 set completenessTmpValue 0
2248 set len [llength $attr]
2249 for {set i 1} {$i < $len} {incr i} {
2250 set q [lindex $attr $i]
2251 set l [string first = $q]
2253 set t [string range $q 0 [expr $l - 1]]
2254 set v [string range $q [expr $l + 1] end]
2257 { set useTmpValue $v }
2259 { set relationTmpValue $v }
2261 { set positionTmpValue $v }
2263 { set structureTmpValue $v }
2265 { set truncationTmpValue $v }
2267 { set completenessTmpValue $v }
2271 if {[winfo exists $w]} {
2276 set n [lindex $attr 0]
2277 wm title $w "Index setup $n"
2281 frame $w.top.use -relief ridge -border 2
2282 frame $w.top.relation -relief ridge -border 2
2283 frame $w.top.position -relief ridge -border 2
2284 frame $w.top.structure -relief ridge -border 2
2285 frame $w.top.truncation -relief ridge -border 2
2286 frame $w.top.completeness -relief ridge -border 2
2292 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2294 label $w.top.use.label -text "Use"
2295 listbox $w.top.use.list -geometry 26x10 \
2296 -yscrollcommand "$w.top.use.scroll set"
2297 scrollbar $w.top.use.scroll -orient vertical -border 1
2298 pack $w.top.use.label -side top -fill x \
2300 pack $w.top.use.list -side left -fill both -expand yes \
2302 pack $w.top.use.scroll -side right -fill y \
2304 $w.top.use.scroll config -command "$w.top.use.list yview"
2308 # Relation Attributes
2310 pack $w.top.relation -pady 6 -padx 6 -side top
2311 label $w.top.relation.label -text "Relation" -width 18
2313 pack $w.top.relation.label $w.top.relation.b -fill x
2315 # Position Attributes
2317 pack $w.top.position -pady 6 -padx 6 -side top
2318 label $w.top.position.label -text "Position" -width 18
2320 pack $w.top.position.label $w.top.position.b -fill x
2322 # Structure Attributes
2324 pack $w.top.structure -pady 6 -padx 6 -side top
2325 label $w.top.structure.label -text "Structure" -width 18
2327 pack $w.top.structure.label $w.top.structure.b -fill x
2329 # Truncation Attributes
2331 pack $w.top.truncation -pady 6 -padx 6 -side top
2332 label $w.top.truncation.label -text "Truncation" -width 18
2334 pack $w.top.truncation.label $w.top.truncation.b -fill x
2336 # Completeness Attributes
2338 pack $w.top.completeness -pady 6 -padx 6 -side top
2339 label $w.top.completeness.label -text "Completeness" -width 18
2341 pack $w.top.completeness.label $w.top.completeness.b -fill x
2344 bottom-buttons $w [list \
2345 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2346 {Cancel} [list destroy $w]] 0
2350 proc query-edit-index {queryNo} {
2354 set i [lindex [$w.top.index.list curselection] 0]
2358 set attr [lindex $queryInfoTmp $i]
2359 dputs "Editing no $i $attr"
2360 index-setup $attr $queryNo $i
2363 proc query-delete-index {queryNo} {
2365 global queryButtonsTmp
2368 set i [lindex [$w.top.index.list curselection] 0]
2372 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2373 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2374 $w.top.index.list delete $i
2377 proc query-setup {queryNo} {
2383 global queryButtonsTmp
2385 global queryIndexTmp
2388 set queryName [lindex $queryTypes $queryNo]
2389 set queryInfoTmp [lindex $queryInfo $queryNo]
2390 set queryButtonsTmp [lindex $queryButtons $queryNo]
2395 wm title $w "Query setup $queryName"
2399 frame $w.top.lines -relief ridge -border 2
2401 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2405 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2407 button $w.top.lines.add -text "Add" \
2408 -command [list query-add-line $queryNo]
2409 button $w.top.lines.del -text "Remove" \
2410 -command [list query-del-line $queryNo]
2412 pack $w.top.lines.del -fill x -side bottom
2413 pack $w.top.lines.add -fill x -pady 10 -side bottom
2417 frame $w.top.index -relief ridge -border 2
2418 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2420 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2421 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2422 -command [list $w.top.index.list yview]
2423 bind $w.top.index.list <2> [list query-edit-index $queryNo]
2425 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2426 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2428 $w.top.index.list select from 0
2429 $w.top.index.list select to 0
2431 foreach x $queryInfoTmp {
2432 $w.top.index.list insert end [lindex $x 0]
2435 bottom-buttons $w [list \
2436 {Ok} [list query-setup-action $queryNo] \
2437 {Add index} [list query-add-index $queryNo] \
2438 {Edit index} [list query-edit-index $queryNo] \
2439 {Delete index} [list query-delete-index $queryNo] \
2440 {Cancel} [list destroy $w]] 0
2443 proc index-clear {} {
2444 global queryButtonsFind
2447 foreach b $queryButtonsFind {
2448 .lines.$i.e delete 0 end
2453 proc index-query {} {
2454 global queryButtonsFind
2455 global queryInfoFind
2460 foreach b $queryButtonsFind {
2461 set term [string trim [.lines.$i.e get]]
2463 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
2465 set len [string length $term]
2469 if {[string index $term $len] == "?"} {
2471 set term [string range $term 0 [expr $len - 1]]
2473 if {[string index $term 0] == "?"} {
2475 set term [string range $term 1 end]
2477 set term "\{${term}\}"
2478 if {$right && $left} {
2479 set term "@attr 5=3 ${term}"
2481 set term "@attr 5=1 ${term}"
2483 set term "@attr 5=2 ${term}"
2486 set term "@attr $a ${term}"
2489 set qs "@and ${qs} ${term}"
2500 proc index-focus-in {w i} {
2501 global curIndexEntry
2503 $w.$i configure -background red
2504 set curIndexEntry $i
2507 proc index-lines {w realOp buttonInfo queryInfo handle} {
2509 foreach b $buttonInfo {
2510 if {! [winfo exists $w.$i]} {
2511 frame $w.$i -background white -border 1
2513 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
2516 if {! [winfo exists $w.$i.e]} {
2517 entry $w.$i.e -width 32 -relief sunken -border 1
2518 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
2519 bind $w.$i.e <FocusOut> [list $w.$i configure \
2521 pack $w.$i.l -side left
2522 pack $w.$i.e -side left -fill x -expand yes
2523 pack $w.$i -side top -fill x -padx 2 -pady 2
2524 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2525 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2526 bind $w.$i.e <Return> search-request
2529 pack $w.$i.l -side left
2530 pack $w.$i -side top -fill x -padx 2 -pady 2
2535 while {[winfo exists $w.$j]} {
2546 bind $w.$j.e <Tab> "focus $w.$k.e"
2550 bind $w.$i.e <Tab> "focus $w.0.e"
2555 proc search-fields {w buttondefs} {
2557 foreach buttondef $buttondefs {
2558 frame $w.$i -background white
2560 listbutton $w.$i.l 0 $buttondef
2561 entry $w.$i.e -width 32 -relief sunken
2563 pack $w.$i.l -side left
2564 pack $w.$i.e -side left -fill x -expand yes
2566 pack $w.$i -side top -fill x -padx 2 -pady 2
2568 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2569 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2577 bind $w.$j.e <Tab> "focus $w.$k.e \n
2578 $w.$k configure -background red \n
2579 $w.$j configure -background white"
2582 bind $w.$i.e <Tab> "focus $w.0.e \n
2583 $w.0 configure -background red \n
2584 $w.$i configure -background white"
2586 $w.0 configure -background red
2589 if {[info exists windowGeometry(.)]} {
2590 set g $windowGeometry(.)
2598 frame .top -border 1 -relief raised
2599 frame .lines -border 1 -relief raised
2600 frame .mid -border 1 -relief raised
2601 frame .data -border 1 -relief raised
2602 frame .bot -border 1 -relief raised
2603 pack .top .lines .mid -side top -fill x
2604 pack .data -side top -fill both -expand yes
2607 menubutton .top.file -text "File" -menu .top.file.m
2609 .top.file.m add command -label "Save settings" -command {save-settings}
2610 .top.file.m add separator
2611 .top.file.m add command -label "Exit" -command {exit-action}
2613 menubutton .top.target -text "Target" -menu .top.target.m
2615 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
2616 .top.target.m add command -label "Disconnect" -command {close-target}
2617 .top.target.m add command -label "About" -command {about-target}
2618 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
2619 .top.target.m add command -label "Setup new" -command {define-target-dialog}
2620 .top.target.m add separator
2623 .top.target.m disable 1
2624 .top.target.m disable 2
2626 menu .top.target.m.clist
2627 menu .top.target.m.slist
2630 menubutton .top.service -text "Service" -menu .top.service.m
2632 .top.service.m add command -label "Database" -command {database-select}
2633 .top.service.m add cascade -label "Present" -menu .top.service.m.present
2634 menu .top.service.m.present
2635 .top.service.m.present add command -label "10 More" \
2636 -command [list present-more 10]
2637 .top.service.m.present add command -label "All" \
2638 -command [list present-more {}]
2639 .top.service.m add command -label "Search" -command {search-request}
2640 .top.service.m add command -label "Scan" -command {scan-request}
2642 .top.service configure -state disabled
2644 menubutton .top.rset -text "Set" -menu .top.rset.m
2646 .top.rset.m add command -label "Load" -command {load-set}
2647 .top.rset.m add separator
2649 menubutton .top.options -text "Options" -menu .top.options.m
2651 .top.options.m add cascade -label "Query" -menu .top.options.m.query
2652 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
2653 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
2655 menu .top.options.m.query
2656 .top.options.m.query add cascade -label "Select" \
2657 -menu .top.options.m.query.clist
2658 .top.options.m.query add cascade -label "Edit" \
2659 -menu .top.options.m.query.slist
2660 .top.options.m.query add command -label "New" \
2661 -command {query-new}
2662 .top.options.m.query add cascade -label "Delete" \
2663 -menu .top.options.m.query.dlist
2665 menu .top.options.m.query.slist
2666 menu .top.options.m.query.clist
2667 menu .top.options.m.query.dlist
2670 menu .top.options.m.formats
2672 foreach f $displayFormats {
2673 .top.options.m.formats add radiobutton -label $f -value $i \
2674 -command [list set-display-format $i] -variable displayFormat
2678 menu .top.options.m.wrap
2679 .top.options.m.wrap add radiobutton -label "Character" \
2680 -value char -variable textWrap -command {set-wrap char}
2681 .top.options.m.wrap add radiobutton -label "Word" \
2682 -value word -variable textWrap -command {set-wrap word}
2683 .top.options.m.wrap add radiobutton -label "None" \
2684 -value none -variable textWrap -command {set-wrap none}
2686 menubutton .top.help -text "Help" -menu .top.help.m
2689 .top.help.m add command -label "Help on help" \
2690 -command {tkerror "Help on help not available. Sorry"}
2691 .top.help.m add command -label "About" -command {about-origin}
2693 pack .top.file .top.target .top.service .top.rset .top.options -side left
2694 pack .top.help -side right
2696 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
2698 button .mid.search -width 7 -text {Search} -command search-request \
2700 button .mid.scan -width 7 -text {Scan} \
2701 -command scan-request -state disabled
2702 button .mid.present -width 7 -text {Present} -command [list present-more 10] \
2705 button .mid.clear -width 7 -text {Clear} -command index-clear
2706 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
2707 -fill y -padx 5 -pady 3
2709 text .data.record -height 2 -width 20 -wrap none \
2710 -yscrollcommand [list .data.scroll set] -wrap $textWrap
2711 scrollbar .data.scroll -command [list .data.record yview]
2712 pack .data.scroll -side right -fill y
2713 pack .data.record -expand yes -fill both
2716 if {[tk colormodel .] == "color"} {
2717 .data.record tag configure marc-tag -foreground blue
2718 .data.record tag configure marc-id -foreground red
2720 .data.record tag configure marc-tag -foreground black
2721 .data.record tag configure marc-id -foreground black
2723 .data.record tag configure marc-data -foreground black
2725 button .bot.logo -bitmap @book1 -command cancel-operation
2727 pack .bot.a -side left -fill x
2728 pack .bot.logo -side right -padx 2 -pady 2
2730 message .bot.a.target -text "" -aspect 1000 -border 1
2732 label .bot.a.status -text "Not connected" -width 15 -relief \
2733 sunken -anchor w -border 1
2734 label .bot.a.set -text "" -width 5 -relief \
2735 sunken -anchor w -border 1
2736 label .bot.a.message -text "" -width 15 -relief \
2737 sunken -anchor w -border 1
2739 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
2740 pack .bot.a.status .bot.a.set .bot.a.message \
2741 -side left -padx 2 -pady 2