3 # Revision 1.27 1995-06-02 14:29:42 adam
4 # Work on scan interface - up/down buttons.
6 # Revision 1.26 1995/06/01 16:36:46 adam
7 # About buttons. Minor bug fixes.
9 # Revision 1.25 1995/05/31 13:09:57 adam
10 # Client searches/presents may be interrupted.
11 # New moving book-logo.
13 # Revision 1.24 1995/05/31 08:36:24 adam
14 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
15 # New method: referenceId. More work on scan.
17 # Revision 1.23 1995/05/29 10:33:41 adam
18 # README and rename of startup script.
20 # Revision 1.22 1995/05/26 11:44:09 adam
21 # Bugs fixed. More work on MARC utilities and queries. Test
22 # client is up-to-date again.
24 # Revision 1.21 1995/05/11 15:34:46 adam
25 # Scan request changed a bit. This version works with RLG.
27 # Revision 1.20 1995/04/21 16:31:57 adam
28 # New radiobutton: protocol (z39v2/SR).
30 # Revision 1.19 1995/04/18 16:11:50 adam
31 # First version of graphical Scan. Some work on query-by-form.
33 # Revision 1.18 1995/04/10 10:50:22 adam
34 # Result-set name defaults to suffix of ir-set name.
35 # Started working on scan. Not finished at this point.
37 # Revision 1.17 1995/03/31 09:34:57 adam
38 # Search-button disabled when there is no connection.
40 # Revision 1.16 1995/03/31 08:56:36 adam
41 # New button "Search".
43 # Revision 1.15 1995/03/28 12:45:22 adam
44 # New ir method failback: called on disconnect/protocol error.
45 # New ir set/get method: protocol: SR / Z3950.
46 # Simple popup and disconnect when failback is invoked.
48 # Revision 1.14 1995/03/22 16:07:55 adam
51 # Revision 1.13 1995/03/21 17:27:26 adam
52 # Short-hand keys in setup.
54 # Revision 1.12 1995/03/21 13:41:03 adam
55 # Comstack cs_create not used too often. Non-blocking connect.
57 # Revision 1.11 1995/03/21 10:39:06 adam
58 # Diagnostic error message displayed with tkerror.
60 # Revision 1.10 1995/03/20 15:24:06 adam
61 # Diagnostic records saved on searchResponse.
63 # Revision 1.9 1995/03/17 18:26:16 adam
64 # Non-blocking i/o used now. Database names popup as cascade items.
66 # Revision 1.8 1995/03/17 15:45:00 adam
67 # Improved target/database setup.
69 # Revision 1.7 1995/03/16 17:54:03 adam
70 # Minor changes really.
72 # Revision 1.6 1995/03/15 19:10:20 adam
73 # Database setup in protocol-setup (rather target setup).
75 # Revision 1.5 1995/03/15 13:59:23 adam
78 # Revision 1.4 1995/03/14 17:32:29 adam
79 # Presentation of full Marc record in popup window.
81 # Revision 1.3 1995/03/12 19:31:52 adam
82 # Pattern matching implemented when retrieving MARC records. More
83 # diagnostic functions.
85 # Revision 1.2 1995/03/10 18:00:15 adam
86 # Actual presentation in line-by-line format. RPN query support.
88 # Revision 1.1 1995/03/09 16:15:07 adam
89 # First presentRequest attempts. Hot-target list.
96 set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} z39v2}
104 set queryTypes {Simple}
105 set queryButtons { { {I 0} {I 1} {I 2} } }
106 set queryInfo { { {Title {1=4}} {Author {1=1}} \
107 {Subject {1=21}} {Any {1=1016}} } }
111 if {[file readable "clientrc.tcl"]} {
112 source "clientrc.tcl"
115 set queryButtonsFind [lindex $queryButtons 0]
116 set queryInfoFind [lindex $queryInfo 0]
118 proc top-down-window {w} {
119 frame $w.top -relief raised -border 1
120 frame $w.bot -relief raised -border 1
122 pack $w.top -side top -fill both -expand yes
123 pack $w.bot -fill both
126 proc top-down-ok-cancel {w ok-action g} {
127 frame $w.bot.left -relief sunken -border 1
128 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 5 -pady 5
129 button $w.bot.left.ok -width 6 -text {Ok} \
130 -command ${ok-action}
131 pack $w.bot.left.ok -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3
132 button $w.bot.cancel -width 6 -text {Cancel} \
133 -command "destroy $w"
134 pack $w.bot.cancel -side left -expand yes
142 proc bottom-buttons {w buttonList g} {
144 set l [llength $buttonList]
146 frame $w.bot.$i -relief sunken -border 1
147 pack $w.bot.$i -side left -expand yes -padx 5 -pady 5
148 button $w.bot.$i.ok -text [lindex $buttonList $i] \
149 -command [lindex $buttonList [expr $i+1]]
150 pack $w.bot.$i.ok -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3 -side left
154 button $w.bot.$i -text [lindex $buttonList $i] \
155 -command [lindex $buttonList [expr $i+1]]
156 pack $w.bot.$i -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3 -side left
166 proc cancel-operation {} {
172 show-status Cancelled 0 {}
176 proc show-target {target} {
177 .bot.a.target configure -text "$target"
180 proc show-logo {v1} {
187 .bot.logo configure -bitmap @book${v1}
188 after 140 [list show-logo $v1]
192 .bot.logo configure -bitmap @book1
201 proc show-status {status b sb} {
205 .bot.a.status configure -text "$status"
207 if {$busy == 0} {set busy 1}
215 .top.search configure -state normal
216 .mid.search configure -state normal
217 .mid.scan configure -state normal
218 .mid.present configure -state normal
219 if {[winfo exists .scan-window]} {
220 .scan-window.bot.2 configure -state normal
221 .scan-window.bot.4 configure -state normal
225 .top.search configure -state disabled
226 .mid.search configure -state disabled
227 .mid.scan configure -state disabled
228 .mid.present configure -state disabled
230 if {[winfo exists .scan-window]} {
231 .scan-window.bot.2 configure -state disabled
232 .scan-window.bot.4 configure -state disabled
238 proc show-message {msg} {
239 .bot.a.message configure -text "$msg"
242 proc insertWithTags {w text args} {
243 set start [$w index insert]
244 $w insert insert $text
245 foreach tag [$w tag names $start] {
246 $w tag remove $tag $start insert
249 $w tag add $i $start insert
253 proc about-target {} {
254 set w .about-target-w
258 wm title $w "About target"
262 set i [z39 targetImplementationName]
263 label $w.top.in -text "Implementation name: $i"
264 set i [z39 targetImplementationId]
265 label $w.top.ii -text "Implementation id: $i"
266 set i [z39 targetImplementationVersion]
267 label $w.top.iv -text "Implementation version: $i"
269 label $w.top.op -text "Protocol options: $i"
271 pack $w.top.in $w.top.ii $w.top.iv $w.top.op -side top -anchor nw
273 bottom-buttons $w [list {Close} [list destroy $w]] 1
276 proc about-origin {} {
277 set w .about-origin-w
281 wm title $w "About IrTcl"
285 set i [z39 implementationName]
286 label $w.top.in -text "Implementation name: $i"
287 set i [z39 implementationId]
288 label $w.top.ii -text "Implementation id: $i"
290 pack $w.top.in $w.top.ii -side top -anchor nw
292 bottom-buttons $w [list {Close} [list destroy $w]] 1
295 proc show-full-marc {no b} {
299 if {[z39.$setNo type $no] != "DB"} {
303 set w .full-marc-$fullMarcSeq
308 if {[winfo exists $w]} {
309 $w.top.record delete 0.0 end
317 frame $w.top -relief raised -border 1
318 frame $w.bot -relief raised -border 1
320 pack $w.top -side top -fill both -expand yes
321 pack $w.bot -fill both
323 text $w.top.record -width 60 -height 12 -wrap word \
324 -yscrollcommand [list $w.top.s set]
325 scrollbar $w.top.s -command [list $w.top.record yview]
329 set r [z39.$setNo getMarc $no list * * *]
331 $w.top.record tag configure marc-tag -foreground blue
332 $w.top.record tag configure marc-data -foreground black
333 $w.top.record tag configure marc-id -foreground red
336 set tag [lindex $line 0]
337 set indicator [lindex $line 1]
338 set fields [lindex $line 2]
340 if {$indicator != ""} {
341 insertWithTags $w.top.record "$tag $indicator" marc-tag
343 insertWithTags $w.top.record "$tag " marc-tag
345 foreach field $fields {
346 set id [lindex $field 0]
347 set data [lindex $field 1]
349 insertWithTags $w.top.record " $id " marc-id
351 set start [$w.top.record index insert]
352 insertWithTags $w.top.record $data {}
354 $w.top.record insert end "\n"
357 bind $w <Return> {destroy .full-marc}
359 pack $w.top.s -side right -fill y
360 pack $w.top.record -expand yes -fill both
362 bottom-buttons $w [list \
363 {Close} [list destroy $w] \
364 {Duplicate} [list show-full-marc $no 1]] 0
368 proc update-target-hotlist {target} {
371 set len [llength $hotTargets]
373 .top.target.m delete 6 [expr 6+[llength $hotTargets]]
375 set indx [lsearch $hotTargets $target]
377 set hotTargets [lreplace $hotTargets $indx $indx]
379 set hotTargets [linsert $hotTargets 0 $target]
383 proc set-target-hotlist {} {
387 foreach target $hotTargets {
388 .top.target.m add command -label "$i $target" -command \
389 "reopen-target $target {}"
397 proc reopen-target {target base} {
399 open-target $target $base
400 update-target-hotlist $target
403 proc define-target-action {} {
406 set target [.target-define.top.target.entry get]
410 update-target-hotlist $target
411 foreach n [array names profile] {
417 set profile($target) $profile(Default)
418 protocol-setup $target
419 destroy .target-define
422 proc fail-response {target} {
424 tkerror "Target connection closed or protocol error"
427 proc connect-response {target} {
428 puts "connect-response"
433 proc open-target {target base} {
438 z39 comstack [lindex $profile($target) 6]
439 z39 idAuthentication [lindex $profile($target) 3]
440 z39 maximumRecordSize [lindex $profile($target) 4]
441 z39 preferredMessageSize [lindex $profile($target) 5]
442 puts -nonewline "maximumRecordSize="
443 puts [z39 maximumRecordSize]
444 puts -nonewline "preferredMessageSize="
445 puts [z39 preferredMessageSize]
446 show-status {Connecting} 0 0
448 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
450 z39 databaseNames $base
452 z39 failback [list fail-response $target]
453 z39 callback [list connect-response $target]
454 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
455 show-status {Connecting} 1 {}
457 .top.target.m disable 0
458 .top.target.m enable 1
459 .top.target.m enable 2
462 proc close-target {} {
470 show-status {Not connected} 0 0
472 .top.target.m disable 1
473 .top.target.m disable 2
474 .top.target.m enable 0
477 proc load-set-action {} {
481 ir-set z39.$setNo z39
483 set fname [.load-set.top.filename.entry get]
488 show-status {Loading} 1 {}
489 z39.$setNo loadFile $fname
491 set no [z39.$setNo numberOfRecordsReturned]
492 add-title-lines $setNo $no 1
494 show-status {Ready} 0 {}
507 frame $w.top.filename
509 pack $w.top.filename -side top -anchor e -pady 2
511 entry-fields $w.top {filename} \
513 {load-set-action} {destroy .load-set}
515 top-down-ok-cancel $w {load-set-action} 1
519 proc init-request {} {
527 z39 callback {init-response}
528 show-status {Initializing} 1 {}
532 proc init-response {} {
539 show-status {Ready} 0 1
540 if {![z39 initResult]} {
541 set u [z39 userInformationField]
543 tkerror "Connection rejected by target: $u"
547 proc search-request {} {
557 if {$searchEnable == 0} {
560 set query [index-query]
565 ir-set z39.$setNo z39
567 if {[lindex $profile($target) 10] == 1} {
568 z39.$setNo setName $setNo
569 puts "setName=${setNo}"
571 z39.$setNo setName Default
572 puts "setName=Default"
574 if {[lindex $profile($target) 8] == 1} {
575 z39.$setNo queryType rpn
577 if {[lindex $profile($target) 9] == 1} {
578 z39.$setNo queryType ccl
580 z39 callback {search-response}
581 z39.$setNo search $query
582 show-status {Search} 1 0
585 proc scan-request {attr} {
597 z39 callback [list scan-response $attr 0 25]
598 if {![winfo exists $w]} {
608 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
609 -font fixed -geometry 50x14
610 scrollbar $w.top.scroll -orient vertical -border 1
611 pack $w.top.list -side left -fill both -expand yes
612 pack $w.top.scroll -side right -fill y
613 $w.top.scroll config -command [list $w.top.list yview]
615 listbox $w.top.list -font fixed -geometry 60x14
616 pack $w.top.list -side left -fill both -expand yes
619 bottom-buttons $w [list {Close} [list destroy $w] \
620 {Up} [list scan-up $attr] \
621 {Down} [list scan-down $attr]] 0
622 bind $w.top.list <Up> [list scan-up $attr]
623 bind $w.top.list <Down> [list scan-down $attr]
626 z39.scan numberOfTermsRequested 5
627 z39.scan preferredPositionInResponse 1
628 z39.scan scan "${attr} b"
630 show-status {Scan} 1 0
634 proc scan-response {attr start toget} {
638 puts "In scan-response"
639 set m [z39.scan numberOfEntriesReturned]
645 if {![winfo exists .scan-window]} {
646 show-status {Ready} 0 1
651 for {set i 0} {$i < $m} {incr i} {
652 set term [lindex [z39.scan scanLine $i] 1]
653 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
654 $w.top.list insert $i "$nostr $term"
657 $w.top.list delete $start end
658 for {set i 0} {$i < $m} {incr i} {
659 set term [lindex [z39.scan scanLine $i] 1]
660 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
661 $w.top.list insert end "$nostr $term"
665 show-status {Ready} 0 1
669 if {$toget > 0 && $m > 1 && $m < $toget} {
670 set ntoget [expr $toget - $m + 1]
672 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
674 puts "down continue: $q"
676 z39.scan numberOfTermsRequested 10
678 z39.scan numberOfTermsRequested $ntoget
680 z39.scan preferredPositionInResponse 1
681 z39.scan scan "${attr} \{$q\}"
684 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
685 set ntoget [expr - $toget - $m]
687 z39 callback [list scan-response $attr 0 -$ntoget]
688 set q [string range [$w.top.list get 0] 7 end]
689 puts "up continue: $q"
691 z39.scan numberOfTermsRequested 10
692 z39.scan preferredPositionInResponse 11
694 z39.scan numberOfTermsRequested $ntoget
695 z39.scan preferredPositionInResponse [incr ntoget]
697 z39.scan scan "${attr} \{$q\}"
700 show-status {Ready} 0 1
703 proc scan-down {attr} {
707 set scanView [expr $scanView + 5]
708 set s [$w.top.list size]
709 if {$scanView > $s} {
710 z39 callback [list scan-response $attr [expr $s - 1] 30]
711 set q [string range [$w.top.list get [expr $s - 1]] 7 end]
713 z39.scan numberOfTermsRequested 10
714 z39.scan preferredPositionInResponse 1
715 show-status {Scan} 1 0
716 z39.scan scan "${attr} \{$q\}"
719 $w.top.list yview $scanView
722 proc scan-up {attr} {
727 z39 callback [list scan-response $attr 0 -30]
728 set q [string range [$w.top.list get 0] 7 end]
730 z39.scan numberOfTermsRequested 10
731 z39.scan preferredPositionInResponse 11
732 show-status {Scan} 1 0
733 z39.scan scan "${attr} \{$q\}"
736 set scanView [expr $scanView - 5]
737 $w.top.list yview $scanView
740 proc search-response {} {
747 puts "In search-response"
749 show-status {Ready} 0 1
750 show-message "[z39.$setNo resultCount] hits"
751 set setMax [z39.$setNo resultCount]
753 set status [z39.$setNo responseStatus]
754 if {[lindex $status 0] == "NSD"} {
755 set code [lindex $status 1]
756 set msg [lindex $status 2]
757 set addinfo [lindex $status 3]
758 tkerror "NSD$code: $msg: $addinfo"
770 z39 callback {present-response}
771 z39.$setNo present $setOffset 1
772 show-status {Retrieve} 1 0
775 proc present-more {number} {
784 set max [z39.$setNo resultCount]
785 if {$max <= $setMax} {
793 z39 callback {present-response}
795 set toGet [expr $setMax - $setOffset + 1]
799 z39.$setNo present $setOffset $toGet
800 show-status {Retrieve} 1 0
803 proc init-title-lines {} {
804 .data.list delete 0 end
807 proc add-title-lines {setno no offset} {
808 for {set i 0} {$i < $no} {incr i} {
809 set o [expr $i + $offset]
810 set type [z39.$setno type $o]
812 set title [lindex [z39.$setno getMarc $o field 245 * a] 0]
813 set year [lindex [z39.$setno getMarc $o field 260 * c] 0]
814 set nostr [format "%5d" $o]
815 .data.list insert end "$nostr $title - $year"
816 } elseif {$type == "SD"} {
817 set err [lindex [z39.$setno diag $o] 1]
818 set add [lindex [z39.$setno diag $o] 2]
822 .data.list insert end "Error ${err}${add}"
823 } elseif {$type == ""} {
824 .data.list insert end "empty"
829 proc present-response {} {
835 puts "In present-response"
836 set no [z39.$setNo numberOfRecordsReturned]
837 puts "Returned $no records, setOffset $setOffset"
838 add-title-lines $setNo $no $setOffset
839 set setOffset [expr $setOffset + $no]
840 set status [z39.$setNo responseStatus]
841 if {[lindex $status 0] == "NSD"} {
842 show-status {Ready} 0 1
843 set code [lindex $status 1]
844 set msg [lindex $status 2]
845 set addinfo [lindex $status 3]
846 tkerror "NSD$code: $msg: $addinfo"
850 show-status {Ready} 0 1
854 if {$no > 0 && $setOffset <= $setMax} {
855 puts "present from ${setOffset}"
856 set toGet [expr $setMax - $setOffset + 1]
860 z39.$setNo present $setOffset $toGet
862 show-status {Finished} 0 1
866 proc left-cursor {w} {
867 set i [$w index insert]
874 proc right-cursor {w} {
875 set i [$w index insert]
880 proc bind-fields {list returnAction escapeAction} {
881 set max [expr [llength $list]-1]
882 for {set i 0} {$i < $max} {incr i} {
883 bind [lindex $list $i] <Return> $returnAction
884 bind [lindex $list $i] <Escape> $escapeAction
885 bind [lindex $list $i] <Tab> [list focus [lindex $list [expr $i+1]]]
886 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
887 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
889 bind [lindex $list $i] <Return> $returnAction
890 bind [lindex $list $i] <Escape> $escapeAction
891 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
892 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
893 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
894 focus [lindex $list 0]
897 proc entry-fields {parent list tlist returnAction escapeAction} {
900 foreach field $list {
901 set label ${parent}.${field}.label
902 set entry ${parent}.${field}.entry
903 label $label -text [lindex $tlist $i] -anchor e
904 entry $entry -width 32 -relief sunken
905 pack $label -side left
906 pack $entry -side right
910 bind-fields $alist $returnAction $escapeAction
913 proc define-target-dialog {} {
921 -side top -anchor e -pady 2
922 entry-fields $w.top {target} \
924 {define-target-action} {destroy .target-define}
925 top-down-ok-cancel $w {define-target-action} 1
928 proc protocol-setup-action {target} {
931 global protocolRadioType
932 global settingsChanged
935 global ResultSetCheck
937 set w .setup-${target}.top
939 #set w .protocol-setup.top
942 set settingsChanged 1
943 set len [$w.databases.list size]
944 for {set i 0} {$i < $len} {incr i} {
945 lappend b [$w.databases.list get $i]
947 set profile($target) [list [$w.description.entry get] \
948 [$w.host.entry get] \
949 [$w.port.entry get] \
950 [$w.idAuthentication.entry get] \
951 [$w.maximumRecordSize.entry get] \
952 [$w.preferredMessageSize.entry get] \
961 puts $profile($target)
962 destroy .setup-${target}
965 proc place-force {window parent} {
966 set g [wm geometry $parent]
968 set p1 [string first + $g]
969 set p2 [string last + $g]
971 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
972 set y [expr 60+[string range $g [expr $p2 +1] end]]
973 wm geometry $window +${x}+${y}
976 proc add-database-action {target} {
977 set w .setup-${target}
979 ${w}.top.databases.list insert end \
980 [.database-select.top.database.entry get]
981 destroy .database-select
984 proc add-database {target} {
985 set w .database-select
990 place-force $w .setup-${target}
994 frame $w.top.database
996 pack $w.top.database -side top -anchor e -pady 2
998 entry-fields $w.top {database} \
999 {{Database to add:}} \
1000 [list add-database-action $target] {destroy .database-select}
1002 top-down-ok-cancel $w [list add-database-action $target] 1
1006 proc delete-database {target} {
1007 set w .setup-${target}
1009 foreach i [lsort -decreasing \
1010 [$w.top.databases.list curselection]] {
1011 $w.top.databases.list delete $i
1015 proc protocol-setup {target} {
1016 set w .setup-$target
1020 global protocolRadioType
1023 global ResultSetCheck
1027 wm title $w "Setup $target"
1032 if {$target == ""} {
1036 puts $profile($target)
1040 frame $w.top.description
1041 frame $w.top.idAuthentication
1042 frame $w.top.maximumRecordSize
1043 frame $w.top.preferredMessageSize
1044 frame $w.top.cs-type -relief ridge -border 2
1045 frame $w.top.protocol -relief ridge -border 2
1046 frame $w.top.query -relief ridge -border 2
1047 frame $w.top.databases -relief ridge -border 2
1049 # Maximum/preferred/idAuth ...
1050 pack $w.top.description $w.top.host $w.top.port \
1051 $w.top.idAuthentication $w.top.maximumRecordSize \
1052 $w.top.preferredMessageSize -side top -anchor e -pady 2
1054 entry-fields $w.top {description host port idAuthentication \
1055 maximumRecordSize preferredMessageSize} \
1056 {{Description:} {Host:} {Port:} {Id Authentication:} \
1057 {Maximum Record Size:} {Preferred Message Size:}} \
1058 [list protocol-setup-action $target] [list destroy $w]
1060 foreach sub {description host port idAuthentication \
1061 maximumRecordSize preferredMessageSize} {
1063 bind $w.top.$sub.entry <Control-a> "add-database $target"
1064 bind $w.top.$sub.entry <Control-d> "delete-database $target"
1066 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1067 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1068 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1069 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1070 $w.top.maximumRecordSize.entry insert 0 [lindex $profile($target) 4]
1071 $w.top.preferredMessageSize.entry insert 0 [lindex $profile($target) 5]
1072 set csRadioType [lindex $profile($target) 6]
1073 set RPNCheck [lindex $profile($target) 8]
1074 set CCLCheck [lindex $profile($target) 9]
1075 set ResultSetCheck [lindex $profile($target) 10]
1076 set protocolRadioType [lindex $profile($target) 11]
1077 if {$protocolRadioType == ""} {
1078 set protocolRadioType z39v2
1082 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill both
1084 label $w.top.databases.label -text "Databases"
1085 button $w.top.databases.add -text "Add" \
1086 -command "add-database $target"
1087 button $w.top.databases.delete -text "Delete" \
1088 -command "delete-database $target"
1089 listbox $w.top.databases.list -geometry 20x6 \
1090 -yscrollcommand "$w.top.databases.scroll set"
1091 scrollbar $w.top.databases.scroll -orient vertical -border 1
1092 pack $w.top.databases.label -side top -fill x \
1094 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1096 pack $w.top.databases.list -side left -fill both -expand yes \
1098 pack $w.top.databases.scroll -side right -fill y \
1100 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1102 foreach b [lindex $profile($target) 7] {
1103 $w.top.databases.list insert end $b
1107 pack $w.top.cs-type -pady 6 -padx 6 -side top -fill x
1109 label $w.top.cs-type.label -text "Transport"
1110 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1111 -command {puts tcp/ip} -variable csRadioType -value tcpip
1112 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1113 -command {puts mosi} -variable csRadioType -value mosi
1115 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1116 -padx 4 -side top -fill x
1119 pack $w.top.protocol -pady 6 -padx 6 -side top -fill x
1121 label $w.top.protocol.label -text "Protocol"
1122 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1123 -command {puts z39v2} -variable protocolRadioType -value z39v2
1124 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1125 -command {puts sr} -variable protocolRadioType -value sr
1127 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1128 -padx 4 -side top -fill x
1131 pack $w.top.query -pady 6 -padx 6 -side top -fill x
1133 label $w.top.query.label -text "Query support"
1134 checkbutton $w.top.query.c1 -text "RPN query" -anchor w -variable RPNCheck
1135 checkbutton $w.top.query.c2 -text "CCL query" -anchor w -variable CCLCheck
1136 checkbutton $w.top.query.c3 -text "Result sets" -anchor w -variable ResultSetCheck
1138 pack $w.top.query.label -side top
1139 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
1140 -padx 4 -side top -fill x
1143 top-down-ok-cancel $w [list protocol-setup-action $target] 0
1146 proc database-select-action {} {
1147 set w .database-select.top
1149 foreach indx [$w.databases.list curselection] {
1150 lappend b [$w.databases.list get $indx]
1153 z39 databaseNames $b
1155 destroy .database-select
1158 proc database-select {} {
1159 set w .database-select
1169 frame $w.top.databases -relief ridge -border 2
1171 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
1173 label $w.top.databases.label -text "List"
1174 listbox $w.top.databases.list -geometry 20x6 \
1175 -yscrollcommand "$w.top.databases.scroll set"
1176 scrollbar $w.top.databases.scroll -orient vertical -border 1
1177 pack $w.top.databases.label -side top -fill x \
1179 pack $w.top.databases.list -side left -fill both -expand yes \
1181 pack $w.top.databases.scroll -side right -fill y \
1183 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1185 foreach b [lindex $profile($hostid) 7] {
1186 $w.top.databases.list insert end $b
1188 top-down-ok-cancel $w {database-select-action} 1
1191 proc cascade-target-list {} {
1194 foreach sub [winfo children .top.target.m.clist] {
1195 puts "deleting $sub"
1198 .top.target.m.clist delete 0 last
1199 foreach n [array names profile] {
1200 if {$n != "Default"} {
1201 set nl [string tolower $n]
1202 if {[llength [lindex $profile($n) 7]] > 1} {
1203 .top.target.m.clist add cascade -label $n \
1204 -menu .top.target.m.clist.$nl
1205 menu .top.target.m.clist.$nl
1206 foreach b [lindex $profile($n) 7] {
1207 .top.target.m.clist.$nl add command -label $b \
1208 -command "reopen-target $n $b"
1211 .top.target.m.clist add command -label $n \
1212 -command "reopen-target $n {}"
1216 .top.target.m.slist delete 0 last
1217 foreach n [array names profile] {
1218 if {$n != "Default"} {
1219 .top.target.m.slist add command -label $n \
1220 -command "protocol-setup $n"
1225 proc cascade-query-list {} {
1229 .top.query.m.slist delete 0 last
1230 foreach n $queryTypes {
1231 .top.query.m.slist add command -label $n \
1232 -command [list query-setup $i]
1237 .top.query.m.clist delete 0 last
1238 foreach n $queryTypes {
1239 .top.query.m.clist add command -label $n \
1240 -command [list query-select $i]
1245 proc save-settings {} {
1248 global settingsChanged
1253 set f [open "clientrc.tcl" w]
1254 puts $f "# Setup file"
1255 puts $f "set hotTargets \{ $hotTargets \}"
1257 foreach n [array names profile] {
1258 puts -nonewline $f "set profile($n) \{"
1259 puts -nonewline $f $profile($n)
1262 puts -nonewline $f "set queryTypes \{"
1263 puts -nonewline $f $queryTypes
1266 puts -nonewline $f "set queryButtons \{"
1267 puts -nonewline $f $queryButtons
1270 puts -nonewline $f "set queryInfo \{"
1271 puts -nonewline $f $queryInfo
1275 set settingsChanged 0
1287 message $w.top.message -text $ask
1289 pack $w.top.message -side left -pady 6 -padx 20 -expand yes -fill x
1292 top-down-ok-cancel $w {alert-action} 1
1296 proc alert-action {} {
1302 proc exit-action {} {
1303 global settingsChanged
1305 if {$settingsChanged} {
1306 set a [alert "you havent saved your settings. Do you wish to save?"]
1314 proc listbuttonaction {w name h user i} {
1315 $w configure -text [lindex $name 0]
1316 $h [lindex $name 1] $user $i
1319 proc listbuttonx {button no names handle user} {
1320 if {[winfo exists $button]} {
1321 $button configure -text [lindex [lindex $names $no] 0]
1322 ${button}.m delete 0 last
1324 menubutton $button -text [lindex [lindex $names $no] 0] \
1325 -width 10 -menu ${button}.m -relief raised -border 1
1329 foreach name $names {
1330 ${button}.m add command -label [lindex $name 0] \
1331 -command [list listbuttonaction ${button} $name \
1337 proc listbutton {button no names} {
1338 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
1339 -relief raised -border 1
1341 foreach name $names {
1342 ${button}.m add command -label $name \
1343 -command [list ${button} configure -text $name]
1347 proc query-add-index-action {queryNo} {
1348 set w .setup-query-$queryNo
1351 global queryButtonsTmp
1353 lappend queryInfoTmp [list [.query-add-index.top.index.entry get] {}]
1355 destroy .query-add-index
1356 #destroy $w.top.lines
1357 #frame $w.top.lines -relief ridge -border 2
1358 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1359 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
1362 proc query-add-line {queryNo} {
1363 set w .setup-query-$queryNo
1366 global queryButtonsTmp
1368 lappend queryButtonsTmp {I 0}
1370 #destroy $w.top.lines
1371 #frame $w.top.lines -relief ridge -border 2
1372 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1373 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
1376 proc query-del-line {queryNo} {
1377 set w .setup-query-$queryNo
1380 global queryButtonsTmp
1382 set l [llength $queryButtonsTmp]
1387 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
1388 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1391 proc query-add-index {queryNo} {
1392 set w .query-add-index
1395 place-force $w .setup-query-$queryNo
1399 -side top -anchor e -pady 2
1400 entry-fields $w.top {index} \
1402 [list query-add-index-action $queryNo] {destroy .query-add-index}
1403 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
1406 proc query-setup-action {queryNo} {
1409 global queryButtonsTmp
1411 global queryButtonsFind
1412 global queryInfoFind
1414 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
1416 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
1418 set queryInfoFind $queryInfoTmp
1419 set queryButtonsFind $queryButtonsTmp
1423 destroy .setup-query-$queryNo
1425 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
1428 proc activate-e-index {value no i} {
1429 global queryButtonsTmp
1431 puts $queryButtonsTmp
1432 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
1433 puts $queryButtonsTmp
1439 proc activate-index {value no i} {
1440 global queryButtonsFind
1442 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
1444 puts "queryButtonsFind $queryButtonsFind"
1450 proc query-setup {queryNo} {
1451 set w .setup-query-$queryNo
1453 set queryTypes {Simple}
1456 global queryButtonsTmp
1459 set queryName [lindex $queryTypes $queryNo]
1460 set queryInfoTmp [lindex $queryInfo $queryNo]
1461 set queryButtonsTmp [lindex $queryButtons $queryNo]
1463 #set queryButtons { {I 0 I 1 I 2} }
1464 #set queryInfo { { {Title ti} {Author au} {Subject sh} } }
1468 wm title $w "Query setup $queryName"
1473 frame $w.top.lines -relief ridge -border 2
1474 frame $w.top.use -relief ridge -border 2
1475 frame $w.top.relation -relief ridge -border 2
1476 frame $w.top.position -relief ridge -border 2
1477 frame $w.top.structure -relief ridge -border 2
1478 frame $w.top.truncation -relief ridge -border 2
1479 frame $w.top.completeness -relief ridge -border 2
1483 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1485 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
1488 pack $w.top.use -side left -pady 6 -padx 6 -fill y
1490 label $w.top.use.label -text "Use"
1491 listbox $w.top.use.list -geometry 20x10 \
1492 -yscrollcommand "$w.top.use.scroll set"
1493 scrollbar $w.top.use.scroll -orient vertical -border 1
1494 pack $w.top.use.label -side top -fill x \
1496 pack $w.top.use.list -side left -fill both -expand yes \
1498 pack $w.top.use.scroll -side right -fill y \
1500 $w.top.use.scroll config -command "$w.top.use.list yview"
1502 foreach u {{Personal name} {Corporate name}} {
1503 $w.top.use.list insert end $u
1505 # Relation Attributes
1506 pack $w.top.relation -pady 6 -padx 6 -side top
1508 label $w.top.relation.label -text "Relation" -width 18
1510 listbutton $w.top.relation.b 0\
1511 {{None} {Less than} {Greater than or equal} \
1512 {Equal} {Greater than or equal} {Greater than} {Not equal} \
1514 {Stem} {Relevance} {AlwaysMatches}}
1516 pack $w.top.relation.label $w.top.relation.b -fill x
1518 # Position Attributes
1519 pack $w.top.position -pady 6 -padx 6 -side top
1521 label $w.top.position.label -text "Position" -width 18
1523 listbutton $w.top.position.b 0 {{None} {First in field} {First in subfield}
1524 {Any position in field}}
1526 pack $w.top.position.label $w.top.position.b -fill x
1528 # Structure Attributes
1530 pack $w.top.structure -pady 6 -padx 6 -side top
1532 label $w.top.structure.label -text "Structure" -width 18
1534 listbutton $w.top.structure.b 0 {{None} {Phrase} {Word} {Key} {Year}
1535 {Date (norm)} {Word list} {Date (un-norm)} {Name (norm)} {Date (un-norm)}
1536 {Structure} {urx} {free-form} {doc-text} {local-number} {string}
1539 pack $w.top.structure.label $w.top.structure.b -fill x
1541 # Truncation Attributes
1543 pack $w.top.truncation -pady 6 -padx 6 -side top
1545 label $w.top.truncation.label -text "Truncation" -width 18
1547 listbutton $w.top.truncation.b 0 {{Auto} {Right} {Left} {Left and right} \
1548 {No truncation} {Process #} {Re-1} {Re-2}}
1549 pack $w.top.truncation.label $w.top.truncation.b -fill x
1551 # Completeness Attributes
1553 pack $w.top.completeness -pady 6 -padx 6 -side top
1555 label $w.top.completeness.label -text "Truncation" -width 18
1557 listbutton $w.top.completeness.b 0 {{None} {Incomplete subfield} \
1558 {Complete subfield} {Complete field}}
1559 pack $w.top.completeness.label $w.top.completeness.b -fill x
1562 bottom-buttons $w [list \
1563 {Ok} [list query-setup-action $queryNo] \
1564 {Add index} [list query-add-index $queryNo] \
1565 {Add line} [list query-add-line $queryNo] \
1566 {Delete line} [list query-del-line $queryNo] \
1567 {Cancel} [list destroy $w]] 0
1570 proc index-clear {} {
1571 global queryButtonsFind
1574 foreach b $queryButtonsFind {
1575 .lines.$i.e delete 0 end
1580 proc index-query {} {
1581 global queryButtonsFind
1582 global queryInfoFind
1587 foreach b $queryButtonsFind {
1588 set term [string trim [.lines.$i.e get]]
1590 set attr [lindex [lindex $queryInfoFind [lindex $b 1]] 1]
1592 set term "\{${term}\}"
1594 set term "@attr $a ${term}"
1597 set qs "@and ${qs} ${term}"
1608 proc index-lines {w realOp buttonInfo queryInfo handle} {
1610 foreach b $buttonInfo {
1611 if {! [winfo exists $w.$i]} {
1612 frame $w.$i -background white -border 1
1614 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
1617 if {! [winfo exists $w.$i.e]} {
1618 entry $w.$i.e -width 32 -relief sunken -border 1
1619 bind $w.$i.e <FocusIn> [list $w.$i configure \
1621 bind $w.$i.e <FocusOut> [list $w.$i configure \
1623 pack $w.$i.l -side left
1624 pack $w.$i.e -side left -fill x -expand yes
1625 pack $w.$i -side top -fill x -padx 2 -pady 2
1626 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
1627 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
1628 bind $w.$i.e <Return> search-request
1631 pack $w.$i.l -side left
1632 pack $w.$i -side top -fill x -padx 2 -pady 2
1637 while {[winfo exists $w.$j]} {
1648 bind $w.$j.e <Tab> "focus $w.$k.e"
1652 bind $w.$i.e <Tab> "focus $w.0.e"
1657 proc search-fields {w buttondefs} {
1659 foreach buttondef $buttondefs {
1660 frame $w.$i -background white
1662 listbutton $w.$i.l 0 $buttondef
1663 entry $w.$i.e -width 32 -relief sunken
1665 pack $w.$i.l -side left
1666 pack $w.$i.e -side left -fill x -expand yes
1668 pack $w.$i -side top -fill x -padx 2 -pady 2
1670 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
1671 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
1679 bind $w.$j.e <Tab> "focus $w.$k.e \n
1680 $w.$k configure -background red \n
1681 $w.$j configure -background white"
1684 bind $w.$i.e <Tab> "focus $w.0.e \n
1685 $w.0 configure -background red \n
1686 $w.$i configure -background white"
1688 $w.0 configure -background red
1691 frame .top -border 1 -relief raised
1692 frame .lines -border 1 -relief raised
1693 frame .mid -border 1 -relief raised
1694 frame .data -border 1 -relief raised
1695 frame .bot -border 1 -relief raised
1696 pack .top .lines .mid -side top -fill x
1697 pack .data -side top -fill both -expand yes
1700 menubutton .top.file -text "File" -underline 0 -menu .top.file.m
1702 .top.file.m add command -label "Save settings" -command {save-settings}
1703 .top.file.m add command -label "Load Set" -command {load-set}
1704 .top.file.m add separator
1705 .top.file.m add command -label "Exit" -command {exit-action}
1706 .top.file.m add separator
1707 .top.file.m add command -label "About" -command {about-origin}
1709 menubutton .top.target -text "Target" -underline 0 -menu .top.target.m
1711 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
1712 .top.target.m add command -label "Disconnect" -command {close-target}
1713 .top.target.m add command -label "About" -command {about-target}
1714 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
1715 .top.target.m add command -label "Setup new" -command {define-target-dialog}
1716 .top.target.m add separator
1719 .top.target.m disable 1
1720 .top.target.m disable 2
1722 menu .top.target.m.clist
1723 menu .top.target.m.slist
1726 menubutton .top.search -text "Search" -underline 0 -menu .top.search.m
1728 .top.search.m add command -label "Database" -command {database-select}
1729 .top.search.m add cascade -label "Query type" -menu .top.search.m.querytype
1730 menu .top.search.m.querytype
1731 .top.search.m.querytype add radiobutton -label "RPN"
1732 .top.search.m.querytype add radiobutton -label "CCL"
1733 .top.search.m add cascade -label "Present" -menu .top.search.m.present
1734 menu .top.search.m.present
1735 .top.search.m.present add command -label "More" -command [list present-more 10]
1736 .top.search.m.present add command -label "All" -command [list present-more {}]
1737 .top.search configure -state disabled
1739 menubutton .top.query -text "Query" -underline 0 -menu .top.query.m
1741 .top.query.m add cascade -label "Choose" -menu .top.query.m.clist
1742 .top.query.m add command -label "Define" -command {new-query-dialog}
1743 .top.query.m add cascade -label "Edit" -menu .top.query.m.slist
1744 menu .top.query.m.clist
1745 menu .top.query.m.slist
1748 menubutton .top.help -text "Help" -menu .top.help.m
1751 .top.help.m add command -label "Help on help" \
1752 -command {tkerror "Help on help not available. Sorry"}
1753 .top.help.m add command -label "About" \
1754 -command {tkerror "About not available. Sorry"}
1756 pack .top.file .top.target .top.query .top.search -side left
1757 pack .top.help -side right
1759 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
1761 button .mid.search -width 7 -text {Search} -command search-request \
1763 button .mid.scan -width 7 -text {Scan} \
1764 -command [list scan-request "@attr 1=4"] -state disabled
1765 button .mid.present -width 7 -text {Present} -command [list present-more 10] \
1768 button .mid.clear -width 7 -text {Clear} -command index-clear
1769 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
1770 -fill y -padx 5 -pady 3
1772 listbox .data.list -yscrollcommand {.data.scroll set} -font fixed
1773 scrollbar .data.scroll -orient vertical -border 1
1774 pack .data.list -side left -fill both -expand yes
1775 pack .data.scroll -side right -fill y
1776 .data.scroll config -command {.data.list yview}
1778 button .bot.logo -bitmap @book1 -command cancel-operation
1780 pack .bot.a -side left -fill x
1781 pack .bot.logo -side right -padx 2 -pady 2
1783 message .bot.a.target -text "" -aspect 1000 -border 1
1785 label .bot.a.status -text "Not connected" -width 15 -relief \
1786 sunken -anchor w -border 1
1787 label .bot.a.set -textvariable setNo -width 5 -relief \
1788 sunken -anchor w -border 1
1789 label .bot.a.message -text "" -width 15 -relief \
1790 sunken -anchor w -border 1
1792 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
1793 pack .bot.a.status .bot.a.set .bot.a.message \
1794 -side left -padx 2 -pady 2
1796 bind .data.list <Double-Button-1> {set indx [.data.list nearest %y]
1797 show-full-marc [incr indx] 0}