3 # Revision 1.30 1995-06-06 11:35:41 adam
4 # Work on scan. Display of old sets.
6 # Revision 1.29 1995/06/05 14:11:18 adam
7 # Bug fix in present-more.
9 # Revision 1.28 1995/06/02 14:52:13 adam
10 # Minor changes really.
12 # Revision 1.27 1995/06/02 14:29:42 adam
13 # Work on scan interface - up/down buttons.
15 # Revision 1.26 1995/06/01 16:36:46 adam
16 # About buttons. Minor bug fixes.
18 # Revision 1.25 1995/05/31 13:09:57 adam
19 # Client searches/presents may be interrupted.
20 # New moving book-logo.
22 # Revision 1.24 1995/05/31 08:36:24 adam
23 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
24 # New method: referenceId. More work on scan.
26 # Revision 1.23 1995/05/29 10:33:41 adam
27 # README and rename of startup script.
29 # Revision 1.22 1995/05/26 11:44:09 adam
30 # Bugs fixed. More work on MARC utilities and queries. Test
31 # client is up-to-date again.
33 # Revision 1.21 1995/05/11 15:34:46 adam
34 # Scan request changed a bit. This version works with RLG.
36 # Revision 1.20 1995/04/21 16:31:57 adam
37 # New radiobutton: protocol (z39v2/SR).
39 # Revision 1.19 1995/04/18 16:11:50 adam
40 # First version of graphical Scan. Some work on query-by-form.
42 # Revision 1.18 1995/04/10 10:50:22 adam
43 # Result-set name defaults to suffix of ir-set name.
44 # Started working on scan. Not finished at this point.
46 # Revision 1.17 1995/03/31 09:34:57 adam
47 # Search-button disabled when there is no connection.
49 # Revision 1.16 1995/03/31 08:56:36 adam
50 # New button "Search".
52 # Revision 1.15 1995/03/28 12:45:22 adam
53 # New ir method failback: called on disconnect/protocol error.
54 # New ir set/get method: protocol: SR / Z3950.
55 # Simple popup and disconnect when failback is invoked.
57 # Revision 1.14 1995/03/22 16:07:55 adam
60 # Revision 1.13 1995/03/21 17:27:26 adam
61 # Short-hand keys in setup.
63 # Revision 1.12 1995/03/21 13:41:03 adam
64 # Comstack cs_create not used too often. Non-blocking connect.
66 # Revision 1.11 1995/03/21 10:39:06 adam
67 # Diagnostic error message displayed with tkerror.
69 # Revision 1.10 1995/03/20 15:24:06 adam
70 # Diagnostic records saved on searchResponse.
72 # Revision 1.9 1995/03/17 18:26:16 adam
73 # Non-blocking i/o used now. Database names popup as cascade items.
75 # Revision 1.8 1995/03/17 15:45:00 adam
76 # Improved target/database setup.
78 # Revision 1.7 1995/03/16 17:54:03 adam
79 # Minor changes really.
81 # Revision 1.6 1995/03/15 19:10:20 adam
82 # Database setup in protocol-setup (rather target setup).
84 # Revision 1.5 1995/03/15 13:59:23 adam
87 # Revision 1.4 1995/03/14 17:32:29 adam
88 # Presentation of full Marc record in popup window.
90 # Revision 1.3 1995/03/12 19:31:52 adam
91 # Pattern matching implemented when retrieving MARC records. More
92 # diagnostic functions.
94 # Revision 1.2 1995/03/10 18:00:15 adam
95 # Actual presentation in line-by-line format. RPN query support.
97 # Revision 1.1 1995/03/09 16:15:07 adam
98 # First presentRequest attempts. Hot-target list.
105 set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} z39v2}
107 set settingsChanged 0
113 set queryTypes {Simple}
114 set queryButtons { { {I 0} {I 1} {I 2} } }
115 set queryInfo { { {Title {1=4}} {Author {1=1}} \
116 {Subject {1=21}} {Any {1=1016}} } }
120 if {[file readable "clientrc.tcl"]} {
121 source "clientrc.tcl"
124 set queryButtonsFind [lindex $queryButtons 0]
125 set queryInfoFind [lindex $queryInfo 0]
127 proc top-down-window {w} {
128 frame $w.top -relief raised -border 1
129 frame $w.bot -relief raised -border 1
131 pack $w.top -side top -fill both -expand yes
132 pack $w.bot -fill both
135 proc top-down-ok-cancel {w ok-action g} {
136 frame $w.bot.left -relief sunken -border 1
137 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 5 -pady 5
138 button $w.bot.left.ok -width 6 -text {Ok} \
139 -command ${ok-action}
140 pack $w.bot.left.ok -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3
141 button $w.bot.cancel -width 6 -text {Cancel} \
142 -command "destroy $w"
143 pack $w.bot.cancel -side left -expand yes
151 proc bottom-buttons {w buttonList g} {
153 set l [llength $buttonList]
155 frame $w.bot.$i -relief sunken -border 1
156 pack $w.bot.$i -side left -expand yes -padx 5 -pady 5
157 button $w.bot.$i.ok -text [lindex $buttonList $i] \
158 -command [lindex $buttonList [expr $i+1]]
159 pack $w.bot.$i.ok -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3 -side left
163 button $w.bot.$i -text [lindex $buttonList $i] \
164 -command [lindex $buttonList [expr $i+1]]
165 pack $w.bot.$i -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3 -side left
175 proc cancel-operation {} {
181 show-status Cancelled 0 {}
185 proc show-target {target} {
186 .bot.a.target configure -text "$target"
189 proc show-logo {v1} {
196 .bot.logo configure -bitmap @book${v1}
197 after 140 [list show-logo $v1]
201 .bot.logo configure -bitmap @book1
210 proc show-status {status b sb} {
214 .bot.a.status configure -text "$status"
216 if {$busy == 0} {set busy 1}
224 .top.service configure -state normal
225 .mid.search configure -state normal
226 .mid.scan configure -state normal
227 .mid.present configure -state normal
228 if {[winfo exists .scan-window]} {
229 .scan-window.bot.2 configure -state normal
230 .scan-window.bot.4 configure -state normal
234 .top.service configure -state disabled
235 .mid.search configure -state disabled
236 .mid.scan configure -state disabled
237 .mid.present configure -state disabled
239 if {[winfo exists .scan-window]} {
240 .scan-window.bot.2 configure -state disabled
241 .scan-window.bot.4 configure -state disabled
247 proc show-message {msg} {
248 .bot.a.message configure -text "$msg"
251 proc insertWithTags {w text args} {
252 set start [$w index insert]
253 $w insert insert $text
254 foreach tag [$w tag names $start] {
255 $w tag remove $tag $start insert
258 $w tag add $i $start insert
262 proc about-target {} {
263 set w .about-target-w
267 wm title $w "About target"
271 set i [z39 targetImplementationName]
272 label $w.top.in -text "Implementation name: $i"
273 set i [z39 targetImplementationId]
274 label $w.top.ii -text "Implementation id: $i"
275 set i [z39 targetImplementationVersion]
276 label $w.top.iv -text "Implementation version: $i"
278 label $w.top.op -text "Protocol options: $i"
280 pack $w.top.in $w.top.ii $w.top.iv $w.top.op -side top -anchor nw
282 bottom-buttons $w [list {Close} [list destroy $w]] 1
285 proc about-origin {} {
286 set w .about-origin-w
290 wm title $w "About IrTcl"
294 set i [z39 implementationName]
295 label $w.top.in -text "Implementation name: $i"
296 set i [z39 implementationId]
297 label $w.top.ii -text "Implementation id: $i"
299 pack $w.top.in $w.top.ii -side top -anchor nw
301 bottom-buttons $w [list {Close} [list destroy $w]] 1
304 proc show-full-marc {sno no b} {
307 if {[z39.$sno type $no] != "DB"} {
311 set w .full-marc-$fullMarcSeq
316 if {[winfo exists $w]} {
317 $w.top.record delete 0.0 end
325 frame $w.top -relief raised -border 1
326 frame $w.bot -relief raised -border 1
328 pack $w.top -side top -fill both -expand yes
329 pack $w.bot -fill both
331 text $w.top.record -width 60 -height 12 -wrap word \
332 -yscrollcommand [list $w.top.s set]
333 scrollbar $w.top.s -command [list $w.top.record yview]
337 set r [z39.$sno getMarc $no list * * *]
339 $w.top.record tag configure marc-tag -foreground blue
340 $w.top.record tag configure marc-data -foreground black
341 $w.top.record tag configure marc-id -foreground red
344 set tag [lindex $line 0]
345 set indicator [lindex $line 1]
346 set fields [lindex $line 2]
348 if {$indicator != ""} {
349 insertWithTags $w.top.record "$tag $indicator" marc-tag
351 insertWithTags $w.top.record "$tag " marc-tag
353 foreach field $fields {
354 set id [lindex $field 0]
355 set data [lindex $field 1]
357 insertWithTags $w.top.record " $id " marc-id
359 set start [$w.top.record index insert]
360 insertWithTags $w.top.record $data {}
362 $w.top.record insert end "\n"
365 bind $w <Return> {destroy .full-marc}
367 pack $w.top.s -side right -fill y
368 pack $w.top.record -expand yes -fill both
370 bottom-buttons $w [list \
371 {Close} [list destroy $w] \
372 {Duplicate} [list show-full-marc $sno $no 1]] 0
376 proc update-target-hotlist {target} {
379 set len [llength $hotTargets]
381 .top.target.m delete 6 [expr 6+[llength $hotTargets]]
383 set indx [lsearch $hotTargets $target]
385 set hotTargets [lreplace $hotTargets $indx $indx]
387 set hotTargets [linsert $hotTargets 0 $target]
391 proc set-target-hotlist {} {
395 foreach target $hotTargets {
396 .top.target.m add command -label "$i $target" -command \
397 "reopen-target $target {}"
405 proc reopen-target {target base} {
407 open-target $target $base
408 update-target-hotlist $target
411 proc define-target-action {} {
414 set target [.target-define.top.target.entry get]
418 update-target-hotlist $target
419 foreach n [array names profile] {
425 set profile($target) $profile(Default)
426 protocol-setup $target
427 destroy .target-define
430 proc fail-response {target} {
432 tkerror "Target connection closed or protocol error"
435 proc connect-response {target} {
436 puts "connect-response"
441 proc open-target {target base} {
446 z39 comstack [lindex $profile($target) 6]
447 z39 idAuthentication [lindex $profile($target) 3]
448 z39 maximumRecordSize [lindex $profile($target) 4]
449 z39 preferredMessageSize [lindex $profile($target) 5]
450 puts -nonewline "maximumRecordSize="
451 puts [z39 maximumRecordSize]
452 puts -nonewline "preferredMessageSize="
453 puts [z39 preferredMessageSize]
454 show-status {Connecting} 0 0
456 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
458 z39 databaseNames $base
460 z39 failback [list fail-response $target]
461 z39 callback [list connect-response $target]
462 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
463 # z39 options search present scan namedResultSets triggerResourceCtrl
464 show-status {Connecting} 1 {}
466 .top.target.m disable 0
467 .top.target.m enable 1
468 .top.target.m enable 2
471 proc close-target {} {
479 show-status {Not connected} 0 0
481 .top.target.m disable 1
482 .top.target.m disable 2
483 .top.target.m enable 0
486 proc load-set-action {} {
490 ir-set z39.$setNo z39
492 set fname [.load-set.top.filename.entry get]
497 show-status {Loading} 1 {}
498 z39.$setNo loadFile $fname
500 set no [z39.$setNo numberOfRecordsReturned]
501 add-title-lines $setNo $no 1
503 set l [format "%-4d %7d" $setNo $no]
504 .top.rset.m add command -label $l \
505 -command [list add-title-lines $setNo 10000 1]
506 show-status {Ready} 0 {}
519 frame $w.top.filename
521 pack $w.top.filename -side top -anchor e -pady 2
523 entry-fields $w.top {filename} \
525 {load-set-action} {destroy .load-set}
527 top-down-ok-cancel $w {load-set-action} 1
531 proc init-request {} {
539 z39 callback {init-response}
540 show-status {Initializing} 1 {}
544 proc init-response {} {
551 show-status {Ready} 0 1
552 if {![z39 initResult]} {
553 set u [z39 userInformationField]
555 tkerror "Connection rejected by target: $u"
559 proc search-request {} {
569 if {$searchEnable == 0} {
572 set query [index-query]
577 ir-set z39.$setNo z39
579 if {[lindex $profile($target) 10] == 1} {
580 z39.$setNo setName $setNo
581 puts "setName=${setNo}"
583 z39.$setNo setName Default
584 puts "setName=Default"
586 if {[lindex $profile($target) 8] == 1} {
587 z39.$setNo queryType rpn
589 if {[lindex $profile($target) 9] == 1} {
590 z39.$setNo queryType ccl
592 z39 callback {search-response}
593 z39.$setNo search $query
594 show-status {Search} 1 0
597 proc scan-request {attr} {
611 if {![winfo exists $w]} {
620 entry $w.top.entry -relief sunken
621 pack $w.top.entry -fill x -padx 4 -pady 2
622 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
624 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
625 -font fixed -geometry 50x14
626 scrollbar $w.top.scroll -orient vertical -border 1
627 pack $w.top.list -side left -fill both -expand yes
628 pack $w.top.scroll -side right -fill y
629 $w.top.scroll config -command [list $w.top.list yview]
631 listbox $w.top.list -font fixed -geometry 60x14
632 pack $w.top.list -side left -fill both -expand yes
635 bottom-buttons $w [list {Close} [list destroy $w] \
636 {Up} [list scan-up $attr] \
637 {Down} [list scan-down $attr]] 0
638 bind $w.top.list <Up> [list scan-up $attr]
639 bind $w.top.list <Down> [list scan-down $attr]
642 z39 callback [list scan-response $attr 0 25]
643 z39.scan numberOfTermsRequested 5
644 z39.scan preferredPositionInResponse 1
645 z39.scan scan "${attr} 0"
647 show-status {Scan} 1 0
650 proc scan-term-h {attr} {
658 set nScanTerm [$w.top.entry get]
659 if {$nScanTerm == $scanTerm} {
662 set scanTerm $nScanTerm
663 z39 callback [list scan-response $attr 0 25]
664 z39.scan numberOfTermsRequested 5
665 z39.scan preferredPositionInResponse 1
666 $w.top.list delete 0 end
667 puts "${attr} \{${scanTerm}\}"
668 if {$scanTerm == ""} {
669 z39.scan scan "${attr} 0"
671 z39.scan scan "${attr} \{${scanTerm}\}"
673 show-status {Scan} 1 0
676 proc scan-response {attr start toget} {
681 puts "In scan-response"
682 set m [z39.scan numberOfEntriesReturned]
688 if {![winfo exists .scan-window]} {
689 show-status {Ready} 0 1
693 set nScanTerm [$w.top.entry get]
694 if {$nScanTerm != $scanTerm} {
695 z39 callback [list scan-response $attr 0 25]
696 z39.scan numberOfTermsRequested 5
697 z39.scan preferredPositionInResponse 1
698 set scanTerm $nScanTerm
699 $w.top.list delete 0 end
700 puts "${attr} \{${scanTerm}\}"
701 if {$scanTerm == ""} {
702 z39.scan scan "${attr} 0"
704 z39.scan scan "${attr} \{${scanTerm}\}"
706 show-status {Scan} 1 0
709 for {set i 0} {$i < $m} {incr i} {
710 set term [lindex [z39.scan scanLine $i] 1]
711 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
712 $w.top.list insert $i "$nostr $term"
715 $w.top.list delete $start end
716 for {set i 0} {$i < $m} {incr i} {
717 set term [lindex [z39.scan scanLine $i] 1]
718 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
719 $w.top.list insert end "$nostr $term"
723 show-status {Ready} 0 1
727 if {$toget > 0 && $m > 1 && $m < $toget} {
728 set ntoget [expr $toget - $m + 1]
730 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
732 puts "down continue: $q"
734 z39.scan numberOfTermsRequested 10
736 z39.scan numberOfTermsRequested $ntoget
738 z39.scan preferredPositionInResponse 1
739 puts "${attr} \{$q\}"
740 z39.scan scan "${attr} \{$q\}"
743 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
744 set ntoget [expr - $toget - $m]
746 z39 callback [list scan-response $attr 0 -$ntoget]
747 set q [string range [$w.top.list get 0] 8 end]
748 puts "up continue: $q"
750 z39.scan numberOfTermsRequested 10
751 z39.scan preferredPositionInResponse 11
753 z39.scan numberOfTermsRequested $ntoget
754 z39.scan preferredPositionInResponse [incr ntoget]
756 puts "${attr} \{$q\}"
757 z39.scan scan "${attr} \{$q\}"
760 show-status {Ready} 0 1
763 proc scan-down {attr} {
767 set scanView [expr $scanView + 5]
768 set s [$w.top.list size]
769 if {$scanView > $s} {
770 z39 callback [list scan-response $attr [expr $s - 1] 30]
771 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
773 z39.scan numberOfTermsRequested 10
774 z39.scan preferredPositionInResponse 1
775 show-status {Scan} 1 0
776 puts "${attr} \{$q\}"
777 z39.scan scan "${attr} \{$q\}"
780 $w.top.list yview $scanView
783 proc scan-up {attr} {
788 z39 callback [list scan-response $attr 0 -30]
789 set q [string range [$w.top.list get 0] 8 end]
791 z39.scan numberOfTermsRequested 10
792 z39.scan preferredPositionInResponse 11
793 show-status {Scan} 1 0
794 z39.scan scan "${attr} \{$q\}"
797 set scanView [expr $scanView - 5]
798 $w.top.list yview $scanView
801 proc search-response {} {
808 puts "In search-response"
810 show-status {Ready} 0 1
811 set setMax [z39.$setNo resultCount]
812 show-message "${setMax} hits"
813 set l [format "%-4d %7d" $setNo $setMax]
814 .top.rset.m add command -label $l \
815 -command [list add-title-lines $setNo 10000 1]
817 set status [z39.$setNo responseStatus]
818 if {[lindex $status 0] == "NSD"} {
819 set code [lindex $status 1]
820 set msg [lindex $status 2]
821 set addinfo [lindex $status 3]
822 tkerror "NSD$code: $msg: $addinfo"
834 z39 callback {present-response}
835 z39.$setNo present $setOffset 1
836 show-status {Retrieve} 1 0
839 proc present-more {number} {
844 puts "setOffset=$setOffset"
850 set max [z39.$setNo resultCount]
851 if {$max <= $setOffset} {
853 puts "setOffset=$setOffset"
860 if {$setMax > $max} {
864 z39 callback {present-response}
866 set toGet [expr $setMax - $setOffset + 1]
873 z39.$setNo present $setOffset $toGet
874 show-status {Retrieve} 1 0
877 proc init-title-lines {} {
878 .data.list delete 0 end
881 proc title-press {y setno} {
882 show-full-marc $setno [expr 1 + [.data.list nearest $y]] 0
885 proc add-title-lines {setno no offset} {
887 .data.list delete 0 end
889 bind .data.list <Double-Button-1> [list title-press %y $setno]
890 for {set i 0} {$i < $no} {incr i} {
891 set o [expr $i + $offset]
892 set type [z39.$setno type $o]
894 set title [lindex [z39.$setno getMarc $o field 245 * a] 0]
895 set year [lindex [z39.$setno getMarc $o field 260 * c] 0]
896 set nostr [format "%5d" $o]
897 .data.list insert end "$nostr $title - $year"
898 } elseif {$type == "SD"} {
899 set err [lindex [z39.$setno diag $o] 1]
900 set add [lindex [z39.$setno diag $o] 2]
904 .data.list insert end "Error ${err}${add}"
905 } elseif {$type == ""} {
911 proc present-response {} {
917 puts "In present-response"
918 set no [z39.$setNo numberOfRecordsReturned]
919 puts "Returned $no records, setOffset $setOffset"
920 add-title-lines $setNo $no $setOffset
921 set setOffset [expr $setOffset + $no]
922 set status [z39.$setNo responseStatus]
923 if {[lindex $status 0] == "NSD"} {
924 show-status {Ready} 0 1
925 set code [lindex $status 1]
926 set msg [lindex $status 2]
927 set addinfo [lindex $status 3]
928 tkerror "NSD$code: $msg: $addinfo"
932 show-status {Ready} 0 1
936 if {$no > 0 && $setOffset <= $setMax} {
937 puts "present from ${setOffset}"
938 set toGet [expr $setMax - $setOffset + 1]
942 z39.$setNo present $setOffset $toGet
944 show-status {Finished} 0 1
948 proc left-cursor {w} {
949 set i [$w index insert]
956 proc right-cursor {w} {
957 set i [$w index insert]
962 proc bind-fields {list returnAction escapeAction} {
963 set max [expr [llength $list]-1]
964 for {set i 0} {$i < $max} {incr i} {
965 bind [lindex $list $i] <Return> $returnAction
966 bind [lindex $list $i] <Escape> $escapeAction
967 bind [lindex $list $i] <Tab> [list focus [lindex $list [expr $i+1]]]
968 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
969 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
971 bind [lindex $list $i] <Return> $returnAction
972 bind [lindex $list $i] <Escape> $escapeAction
973 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
974 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
975 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
976 focus [lindex $list 0]
979 proc entry-fields {parent list tlist returnAction escapeAction} {
982 foreach field $list {
983 set label ${parent}.${field}.label
984 set entry ${parent}.${field}.entry
985 label $label -text [lindex $tlist $i] -anchor e
986 entry $entry -width 32 -relief sunken
987 pack $label -side left
988 pack $entry -side right
992 bind-fields $alist $returnAction $escapeAction
995 proc define-target-dialog {} {
1002 pack $w.top.target \
1003 -side top -anchor e -pady 2
1004 entry-fields $w.top {target} \
1006 {define-target-action} {destroy .target-define}
1007 top-down-ok-cancel $w {define-target-action} 1
1010 proc protocol-setup-action {target} {
1013 global protocolRadioType
1014 global settingsChanged
1017 global ResultSetCheck
1019 set w .setup-${target}.top
1021 #set w .protocol-setup.top
1024 set settingsChanged 1
1025 set len [$w.databases.list size]
1026 for {set i 0} {$i < $len} {incr i} {
1027 lappend b [$w.databases.list get $i]
1029 set profile($target) [list [$w.description.entry get] \
1030 [$w.host.entry get] \
1031 [$w.port.entry get] \
1032 [$w.idAuthentication.entry get] \
1033 [$w.maximumRecordSize.entry get] \
1034 [$w.preferredMessageSize.entry get] \
1040 $protocolRadioType ]
1043 puts $profile($target)
1044 destroy .setup-${target}
1047 proc place-force {window parent} {
1048 set g [wm geometry $parent]
1050 set p1 [string first + $g]
1051 set p2 [string last + $g]
1053 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1054 set y [expr 60+[string range $g [expr $p2 +1] end]]
1055 wm geometry $window +${x}+${y}
1058 proc add-database-action {target} {
1059 set w .setup-${target}
1061 ${w}.top.databases.list insert end \
1062 [.database-select.top.database.entry get]
1063 destroy .database-select
1066 proc add-database {target} {
1067 set w .database-select
1069 set oldFocus [focus]
1072 place-force $w .setup-${target}
1076 frame $w.top.database
1078 pack $w.top.database -side top -anchor e -pady 2
1080 entry-fields $w.top {database} \
1081 {{Database to add:}} \
1082 [list add-database-action $target] {destroy .database-select}
1084 top-down-ok-cancel $w [list add-database-action $target] 1
1088 proc delete-database {target} {
1089 set w .setup-${target}
1091 foreach i [lsort -decreasing \
1092 [$w.top.databases.list curselection]] {
1093 $w.top.databases.list delete $i
1097 proc protocol-setup {target} {
1098 set w .setup-$target
1102 global protocolRadioType
1105 global ResultSetCheck
1109 wm title $w "Setup $target"
1114 if {$target == ""} {
1118 puts $profile($target)
1122 frame $w.top.description
1123 frame $w.top.idAuthentication
1124 frame $w.top.maximumRecordSize
1125 frame $w.top.preferredMessageSize
1126 frame $w.top.cs-type -relief ridge -border 2
1127 frame $w.top.protocol -relief ridge -border 2
1128 frame $w.top.query -relief ridge -border 2
1129 frame $w.top.databases -relief ridge -border 2
1131 # Maximum/preferred/idAuth ...
1132 pack $w.top.description $w.top.host $w.top.port \
1133 $w.top.idAuthentication $w.top.maximumRecordSize \
1134 $w.top.preferredMessageSize -side top -anchor e -pady 2
1136 entry-fields $w.top {description host port idAuthentication \
1137 maximumRecordSize preferredMessageSize} \
1138 {{Description:} {Host:} {Port:} {Id Authentication:} \
1139 {Maximum Record Size:} {Preferred Message Size:}} \
1140 [list protocol-setup-action $target] [list destroy $w]
1142 foreach sub {description host port idAuthentication \
1143 maximumRecordSize preferredMessageSize} {
1145 bind $w.top.$sub.entry <Control-a> "add-database $target"
1146 bind $w.top.$sub.entry <Control-d> "delete-database $target"
1148 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1149 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1150 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1151 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1152 $w.top.maximumRecordSize.entry insert 0 [lindex $profile($target) 4]
1153 $w.top.preferredMessageSize.entry insert 0 [lindex $profile($target) 5]
1154 set csRadioType [lindex $profile($target) 6]
1155 set RPNCheck [lindex $profile($target) 8]
1156 set CCLCheck [lindex $profile($target) 9]
1157 set ResultSetCheck [lindex $profile($target) 10]
1158 set protocolRadioType [lindex $profile($target) 11]
1159 if {$protocolRadioType == ""} {
1160 set protocolRadioType z39v2
1164 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill both
1166 label $w.top.databases.label -text "Databases"
1167 button $w.top.databases.add -text "Add" \
1168 -command "add-database $target"
1169 button $w.top.databases.delete -text "Delete" \
1170 -command "delete-database $target"
1171 listbox $w.top.databases.list -geometry 20x6 \
1172 -yscrollcommand "$w.top.databases.scroll set"
1173 scrollbar $w.top.databases.scroll -orient vertical -border 1
1174 pack $w.top.databases.label -side top -fill x \
1176 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1178 pack $w.top.databases.list -side left -fill both -expand yes \
1180 pack $w.top.databases.scroll -side right -fill y \
1182 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1184 foreach b [lindex $profile($target) 7] {
1185 $w.top.databases.list insert end $b
1189 pack $w.top.cs-type -pady 6 -padx 6 -side top -fill x
1191 label $w.top.cs-type.label -text "Transport"
1192 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1193 -command {puts tcp/ip} -variable csRadioType -value tcpip
1194 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1195 -command {puts mosi} -variable csRadioType -value mosi
1197 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1198 -padx 4 -side top -fill x
1201 pack $w.top.protocol -pady 6 -padx 6 -side top -fill x
1203 label $w.top.protocol.label -text "Protocol"
1204 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1205 -command {puts z39v2} -variable protocolRadioType -value z39v2
1206 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1207 -command {puts sr} -variable protocolRadioType -value sr
1209 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1210 -padx 4 -side top -fill x
1213 pack $w.top.query -pady 6 -padx 6 -side top -fill x
1215 label $w.top.query.label -text "Query support"
1216 checkbutton $w.top.query.c1 -text "RPN query" -anchor w -variable RPNCheck
1217 checkbutton $w.top.query.c2 -text "CCL query" -anchor w -variable CCLCheck
1218 checkbutton $w.top.query.c3 -text "Result sets" -anchor w -variable ResultSetCheck
1220 pack $w.top.query.label -side top
1221 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
1222 -padx 4 -side top -fill x
1225 top-down-ok-cancel $w [list protocol-setup-action $target] 0
1228 proc database-select-action {} {
1229 set w .database-select.top
1231 foreach indx [$w.databases.list curselection] {
1232 lappend b [$w.databases.list get $indx]
1235 z39 databaseNames $b
1237 destroy .database-select
1240 proc database-select {} {
1241 set w .database-select
1251 frame $w.top.databases -relief ridge -border 2
1253 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
1255 label $w.top.databases.label -text "List"
1256 listbox $w.top.databases.list -geometry 20x6 \
1257 -yscrollcommand "$w.top.databases.scroll set"
1258 scrollbar $w.top.databases.scroll -orient vertical -border 1
1259 pack $w.top.databases.label -side top -fill x \
1261 pack $w.top.databases.list -side left -fill both -expand yes \
1263 pack $w.top.databases.scroll -side right -fill y \
1265 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1267 foreach b [lindex $profile($hostid) 7] {
1268 $w.top.databases.list insert end $b
1270 top-down-ok-cancel $w {database-select-action} 1
1273 proc cascade-target-list {} {
1276 foreach sub [winfo children .top.target.m.clist] {
1277 puts "deleting $sub"
1280 .top.target.m.clist delete 0 last
1281 foreach n [array names profile] {
1282 if {$n != "Default"} {
1283 set nl [string tolower $n]
1284 if {[llength [lindex $profile($n) 7]] > 1} {
1285 .top.target.m.clist add cascade -label $n \
1286 -menu .top.target.m.clist.$nl
1287 menu .top.target.m.clist.$nl
1288 foreach b [lindex $profile($n) 7] {
1289 .top.target.m.clist.$nl add command -label $b \
1290 -command "reopen-target $n $b"
1293 .top.target.m.clist add command -label $n \
1294 -command "reopen-target $n {}"
1298 .top.target.m.slist delete 0 last
1299 foreach n [array names profile] {
1300 if {$n != "Default"} {
1301 .top.target.m.slist add command -label $n \
1302 -command "protocol-setup $n"
1307 proc cascade-query-list {} {
1311 .top.options.m.slist delete 0 last
1312 foreach n $queryTypes {
1313 .top.options.m.slist add command -label $n \
1314 -command [list query-setup $i]
1319 .top.options.m.clist delete 0 last
1320 foreach n $queryTypes {
1321 .top.options.m.clist add command -label $n \
1322 -command [list query-select $i]
1327 proc save-settings {} {
1330 global settingsChanged
1335 set f [open "clientrc.tcl" w]
1336 puts $f "# Setup file"
1337 puts $f "set hotTargets \{ $hotTargets \}"
1339 foreach n [array names profile] {
1340 puts -nonewline $f "set profile($n) \{"
1341 puts -nonewline $f $profile($n)
1344 puts -nonewline $f "set queryTypes \{"
1345 puts -nonewline $f $queryTypes
1348 puts -nonewline $f "set queryButtons \{"
1349 puts -nonewline $f $queryButtons
1352 puts -nonewline $f "set queryInfo \{"
1353 puts -nonewline $f $queryInfo
1357 set settingsChanged 0
1369 message $w.top.message -text $ask
1371 pack $w.top.message -side left -pady 6 -padx 20 -expand yes -fill x
1374 top-down-ok-cancel $w {alert-action} 1
1378 proc alert-action {} {
1384 proc exit-action {} {
1385 global settingsChanged
1387 if {$settingsChanged} {
1388 set a [alert "you havent saved your settings. Do you wish to save?"]
1396 proc listbuttonaction {w name h user i} {
1397 $w configure -text [lindex $name 0]
1398 $h [lindex $name 1] $user $i
1401 proc listbuttonx {button no names handle user} {
1402 if {[winfo exists $button]} {
1403 $button configure -text [lindex [lindex $names $no] 0]
1404 ${button}.m delete 0 last
1406 menubutton $button -text [lindex [lindex $names $no] 0] \
1407 -width 10 -menu ${button}.m -relief raised -border 1
1411 foreach name $names {
1412 ${button}.m add command -label [lindex $name 0] \
1413 -command [list listbuttonaction ${button} $name \
1419 proc listbutton {button no names} {
1420 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
1421 -relief raised -border 1
1423 foreach name $names {
1424 ${button}.m add command -label $name \
1425 -command [list ${button} configure -text $name]
1429 proc query-add-index-action {queryNo} {
1430 set w .setup-query-$queryNo
1433 global queryButtonsTmp
1435 lappend queryInfoTmp [list [.query-add-index.top.index.entry get] {}]
1437 destroy .query-add-index
1438 #destroy $w.top.lines
1439 #frame $w.top.lines -relief ridge -border 2
1440 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1441 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
1444 proc query-add-line {queryNo} {
1445 set w .setup-query-$queryNo
1448 global queryButtonsTmp
1450 lappend queryButtonsTmp {I 0}
1452 #destroy $w.top.lines
1453 #frame $w.top.lines -relief ridge -border 2
1454 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1455 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
1458 proc query-del-line {queryNo} {
1459 set w .setup-query-$queryNo
1462 global queryButtonsTmp
1464 set l [llength $queryButtonsTmp]
1469 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
1470 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1473 proc query-add-index {queryNo} {
1474 set w .query-add-index
1477 place-force $w .setup-query-$queryNo
1481 -side top -anchor e -pady 2
1482 entry-fields $w.top {index} \
1484 [list query-add-index-action $queryNo] {destroy .query-add-index}
1485 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
1488 proc query-setup-action {queryNo} {
1491 global queryButtonsTmp
1493 global queryButtonsFind
1494 global queryInfoFind
1496 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
1498 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
1500 set queryInfoFind $queryInfoTmp
1501 set queryButtonsFind $queryButtonsTmp
1505 destroy .setup-query-$queryNo
1507 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
1510 proc activate-e-index {value no i} {
1511 global queryButtonsTmp
1513 puts $queryButtonsTmp
1514 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
1515 puts $queryButtonsTmp
1521 proc activate-index {value no i} {
1522 global queryButtonsFind
1524 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
1526 puts "queryButtonsFind $queryButtonsFind"
1532 proc query-setup {queryNo} {
1533 set w .setup-query-$queryNo
1535 set queryTypes {Simple}
1538 global queryButtonsTmp
1541 set queryName [lindex $queryTypes $queryNo]
1542 set queryInfoTmp [lindex $queryInfo $queryNo]
1543 set queryButtonsTmp [lindex $queryButtons $queryNo]
1545 #set queryButtons { {I 0 I 1 I 2} }
1546 #set queryInfo { { {Title ti} {Author au} {Subject sh} } }
1550 wm title $w "Query setup $queryName"
1555 frame $w.top.lines -relief ridge -border 2
1556 frame $w.top.use -relief ridge -border 2
1557 frame $w.top.relation -relief ridge -border 2
1558 frame $w.top.position -relief ridge -border 2
1559 frame $w.top.structure -relief ridge -border 2
1560 frame $w.top.truncation -relief ridge -border 2
1561 frame $w.top.completeness -relief ridge -border 2
1565 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1567 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
1570 pack $w.top.use -side left -pady 6 -padx 6 -fill y
1572 label $w.top.use.label -text "Use"
1573 listbox $w.top.use.list -geometry 20x10 \
1574 -yscrollcommand "$w.top.use.scroll set"
1575 scrollbar $w.top.use.scroll -orient vertical -border 1
1576 pack $w.top.use.label -side top -fill x \
1578 pack $w.top.use.list -side left -fill both -expand yes \
1580 pack $w.top.use.scroll -side right -fill y \
1582 $w.top.use.scroll config -command "$w.top.use.list yview"
1584 foreach u {{Personal name} {Corporate name}} {
1585 $w.top.use.list insert end $u
1587 # Relation Attributes
1588 pack $w.top.relation -pady 6 -padx 6 -side top
1590 label $w.top.relation.label -text "Relation" -width 18
1592 listbutton $w.top.relation.b 0\
1593 {{None} {Less than} {Greater than or equal} \
1594 {Equal} {Greater than or equal} {Greater than} {Not equal} \
1596 {Stem} {Relevance} {AlwaysMatches}}
1598 pack $w.top.relation.label $w.top.relation.b -fill x
1600 # Position Attributes
1601 pack $w.top.position -pady 6 -padx 6 -side top
1603 label $w.top.position.label -text "Position" -width 18
1605 listbutton $w.top.position.b 0 {{None} {First in field} {First in subfield}
1606 {Any position in field}}
1608 pack $w.top.position.label $w.top.position.b -fill x
1610 # Structure Attributes
1612 pack $w.top.structure -pady 6 -padx 6 -side top
1614 label $w.top.structure.label -text "Structure" -width 18
1616 listbutton $w.top.structure.b 0 {{None} {Phrase} {Word} {Key} {Year}
1617 {Date (norm)} {Word list} {Date (un-norm)} {Name (norm)} {Date (un-norm)}
1618 {Structure} {urx} {free-form} {doc-text} {local-number} {string}
1621 pack $w.top.structure.label $w.top.structure.b -fill x
1623 # Truncation Attributes
1625 pack $w.top.truncation -pady 6 -padx 6 -side top
1627 label $w.top.truncation.label -text "Truncation" -width 18
1629 listbutton $w.top.truncation.b 0 {{Auto} {Right} {Left} {Left and right} \
1630 {No truncation} {Process #} {Re-1} {Re-2}}
1631 pack $w.top.truncation.label $w.top.truncation.b -fill x
1633 # Completeness Attributes
1635 pack $w.top.completeness -pady 6 -padx 6 -side top
1637 label $w.top.completeness.label -text "Truncation" -width 18
1639 listbutton $w.top.completeness.b 0 {{None} {Incomplete subfield} \
1640 {Complete subfield} {Complete field}}
1641 pack $w.top.completeness.label $w.top.completeness.b -fill x
1644 bottom-buttons $w [list \
1645 {Ok} [list query-setup-action $queryNo] \
1646 {Add index} [list query-add-index $queryNo] \
1647 {Add line} [list query-add-line $queryNo] \
1648 {Delete line} [list query-del-line $queryNo] \
1649 {Cancel} [list destroy $w]] 0
1652 proc index-clear {} {
1653 global queryButtonsFind
1656 foreach b $queryButtonsFind {
1657 .lines.$i.e delete 0 end
1662 proc index-query {} {
1663 global queryButtonsFind
1664 global queryInfoFind
1669 foreach b $queryButtonsFind {
1670 set term [string trim [.lines.$i.e get]]
1672 set attr [lindex [lindex $queryInfoFind [lindex $b 1]] 1]
1674 set term "\{${term}\}"
1676 set term "@attr $a ${term}"
1679 set qs "@and ${qs} ${term}"
1690 proc index-lines {w realOp buttonInfo queryInfo handle} {
1692 foreach b $buttonInfo {
1693 if {! [winfo exists $w.$i]} {
1694 frame $w.$i -background white -border 1
1696 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
1699 if {! [winfo exists $w.$i.e]} {
1700 entry $w.$i.e -width 32 -relief sunken -border 1
1701 bind $w.$i.e <FocusIn> [list $w.$i configure \
1703 bind $w.$i.e <FocusOut> [list $w.$i configure \
1705 pack $w.$i.l -side left
1706 pack $w.$i.e -side left -fill x -expand yes
1707 pack $w.$i -side top -fill x -padx 2 -pady 2
1708 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
1709 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
1710 bind $w.$i.e <Return> search-request
1713 pack $w.$i.l -side left
1714 pack $w.$i -side top -fill x -padx 2 -pady 2
1719 while {[winfo exists $w.$j]} {
1730 bind $w.$j.e <Tab> "focus $w.$k.e"
1734 bind $w.$i.e <Tab> "focus $w.0.e"
1739 proc search-fields {w buttondefs} {
1741 foreach buttondef $buttondefs {
1742 frame $w.$i -background white
1744 listbutton $w.$i.l 0 $buttondef
1745 entry $w.$i.e -width 32 -relief sunken
1747 pack $w.$i.l -side left
1748 pack $w.$i.e -side left -fill x -expand yes
1750 pack $w.$i -side top -fill x -padx 2 -pady 2
1752 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
1753 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
1761 bind $w.$j.e <Tab> "focus $w.$k.e \n
1762 $w.$k configure -background red \n
1763 $w.$j configure -background white"
1766 bind $w.$i.e <Tab> "focus $w.0.e \n
1767 $w.0 configure -background red \n
1768 $w.$i configure -background white"
1770 $w.0 configure -background red
1773 frame .top -border 1 -relief raised
1774 frame .lines -border 1 -relief raised
1775 frame .mid -border 1 -relief raised
1776 frame .data -border 1 -relief raised
1777 frame .bot -border 1 -relief raised
1778 pack .top .lines .mid -side top -fill x
1779 pack .data -side top -fill both -expand yes
1782 menubutton .top.file -text "File" -underline 0 -menu .top.file.m
1784 .top.file.m add command -label "Save settings" -command {save-settings}
1785 .top.file.m add separator
1786 .top.file.m add command -label "Exit" -command {exit-action}
1787 .top.file.m add separator
1788 .top.file.m add command -label "About" -command {about-origin}
1790 menubutton .top.target -text "Target" -underline 0 -menu .top.target.m
1792 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
1793 .top.target.m add command -label "Disconnect" -command {close-target}
1794 .top.target.m add command -label "About" -command {about-target}
1795 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
1796 .top.target.m add command -label "Setup new" -command {define-target-dialog}
1797 .top.target.m add separator
1800 .top.target.m disable 1
1801 .top.target.m disable 2
1803 menu .top.target.m.clist
1804 menu .top.target.m.slist
1807 menubutton .top.service -text "Service" -underline 0 -menu .top.service.m
1809 .top.service.m add command -label "Database" -command {database-select}
1810 .top.service.m add cascade -label "Query type" -menu .top.service.m.querytype
1811 menu .top.service.m.querytype
1812 .top.service.m.querytype add radiobutton -label "RPN"
1813 .top.service.m.querytype add radiobutton -label "CCL"
1814 .top.service.m add cascade -label "Present" -menu .top.service.m.present
1815 menu .top.service.m.present
1816 .top.service.m.present add command -label "More" \
1817 -command [list present-more 10]
1818 .top.service.m.present add command -label "All" \
1819 -command [list present-more {}]
1820 .top.service configure -state disabled
1822 menubutton .top.rset -text "Set" -menu .top.rset.m
1824 .top.rset.m add command -label "Load" -command {load-set}
1825 .top.rset.m add separator
1827 menubutton .top.options -text "Options" -underline 0 -menu .top.options.m
1829 .top.options.m add cascade -label "Choose query" -menu .top.options.m.clist
1830 .top.options.m add command -label "Define query" -command {new-query-dialog}
1831 .top.options.m add cascade -label "Edit query" -menu .top.options.m.slist
1832 menu .top.options.m.clist
1833 menu .top.options.m.slist
1836 menubutton .top.help -text "Help" -menu .top.help.m
1839 .top.help.m add command -label "Help on help" \
1840 -command {tkerror "Help on help not available. Sorry"}
1841 .top.help.m add command -label "About" \
1842 -command {tkerror "About not available. Sorry"}
1844 pack .top.file .top.target .top.service .top.rset .top.options -side left
1845 pack .top.help -side right
1847 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
1849 button .mid.search -width 7 -text {Search} -command search-request \
1851 button .mid.scan -width 7 -text {Scan} \
1852 -command [list scan-request "@attr 1=4"] -state disabled
1853 button .mid.present -width 7 -text {Present} -command [list present-more 10] \
1856 button .mid.clear -width 7 -text {Clear} -command index-clear
1857 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
1858 -fill y -padx 5 -pady 3
1860 listbox .data.list -yscrollcommand {.data.scroll set} -font fixed -geometry 20x2
1861 scrollbar .data.scroll -orient vertical -border 1
1862 pack .data.list -side left -fill both -expand yes
1863 pack .data.scroll -side right -fill y
1864 .data.scroll config -command {.data.list yview}
1866 button .bot.logo -bitmap @book1 -command cancel-operation
1868 pack .bot.a -side left -fill x
1869 pack .bot.logo -side right -padx 2 -pady 2
1871 message .bot.a.target -text "" -aspect 1000 -border 1
1873 label .bot.a.status -text "Not connected" -width 15 -relief \
1874 sunken -anchor w -border 1
1875 label .bot.a.set -textvariable setNo -width 5 -relief \
1876 sunken -anchor w -border 1
1877 label .bot.a.message -text "" -width 15 -relief \
1878 sunken -anchor w -border 1
1880 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
1881 pack .bot.a.status .bot.a.set .bot.a.message \
1882 -side left -padx 2 -pady 2