1 # IR toolkit for tcl/tk
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
7 # Revision 1.43 1995-06-16 14:41:05 adam
8 # Scan line entries can be copied to a search entry.
10 # Revision 1.42 1995/06/16 12:28:13 adam
11 # Implemented preferredRecordSyntax.
12 # Minor changes in diagnostic handling.
13 # Record list deleted when connection closes.
15 # Revision 1.41 1995/06/14 15:07:59 adam
16 # Bug fix in cascade-target-list. Uses yaz-version.h.
18 # Revision 1.40 1995/06/14 13:37:17 adam
19 # Setting recordType implemented.
20 # Setting implementationVersion implemented.
21 # Settings implementationId / implementationName edited.
23 # Revision 1.39 1995/06/14 12:16:22 adam
24 # hotTargets, textWrap and displayFormat saved in clientg.tcl.
26 # Revision 1.38 1995/06/14 07:22:45 adam
27 # Target definitions can be deleted.
28 # Listbox used in the query definition dialog.
30 # Revision 1.37 1995/06/13 14:37:59 adam
31 # Work on query setup.
32 # Better about origin/target.
33 # Better presentation formats.
35 # Revision 1.36 1995/06/13 07:42:14 adam
36 # Bindings removed from text widgets.
38 # Revision 1.35 1995/06/12 15:17:31 adam
39 # Text widget used in main window (instead of listbox) to support
40 # better presentation formats.
42 # Revision 1.34 1995/06/12 07:59:07 adam
43 # More work on geometry handling.
45 # Revision 1.33 1995/06/09 11:17:35 adam
46 # Start work on geometry management.
48 # Revision 1.32 1995/06/07 09:16:37 adam
49 # New presentation format.
51 # Revision 1.31 1995/06/06 16:31:09 adam
52 # Bug fix: target names couldn't contain blanks.
55 # Revision 1.30 1995/06/06 11:35:41 adam
56 # Work on scan. Display of old sets.
58 # Revision 1.29 1995/06/05 14:11:18 adam
59 # Bug fix in present-more.
61 # Revision 1.28 1995/06/02 14:52:13 adam
62 # Minor changes really.
64 # Revision 1.27 1995/06/02 14:29:42 adam
65 # Work on scan interface - up/down buttons.
67 # Revision 1.26 1995/06/01 16:36:46 adam
68 # About buttons. Minor bug fixes.
70 # Revision 1.25 1995/05/31 13:09:57 adam
71 # Client searches/presents may be interrupted.
72 # New moving book-logo.
74 # Revision 1.24 1995/05/31 08:36:24 adam
75 # Bug fix in client.tcl: didn't save options on clientrc.tcl.
76 # New method: referenceId. More work on scan.
78 # Revision 1.23 1995/05/29 10:33:41 adam
79 # README and rename of startup script.
81 # Revision 1.22 1995/05/26 11:44:09 adam
82 # Bugs fixed. More work on MARC utilities and queries. Test
83 # client is up-to-date again.
85 # Revision 1.21 1995/05/11 15:34:46 adam
86 # Scan request changed a bit. This version works with RLG.
88 # Revision 1.20 1995/04/21 16:31:57 adam
89 # New radiobutton: protocol (z39v2/SR).
91 # Revision 1.19 1995/04/18 16:11:50 adam
92 # First version of graphical Scan. Some work on query-by-form.
94 # Revision 1.18 1995/04/10 10:50:22 adam
95 # Result-set name defaults to suffix of ir-set name.
96 # Started working on scan. Not finished at this point.
98 # Revision 1.17 1995/03/31 09:34:57 adam
99 # Search-button disabled when there is no connection.
101 # Revision 1.16 1995/03/31 08:56:36 adam
102 # New button "Search".
104 # Revision 1.15 1995/03/28 12:45:22 adam
105 # New ir method failback: called on disconnect/protocol error.
106 # New ir set/get method: protocol: SR / Z3950.
107 # Simple popup and disconnect when failback is invoked.
109 # Revision 1.14 1995/03/22 16:07:55 adam
112 # Revision 1.13 1995/03/21 17:27:26 adam
113 # Short-hand keys in setup.
115 # Revision 1.12 1995/03/21 13:41:03 adam
116 # Comstack cs_create not used too often. Non-blocking connect.
118 # Revision 1.11 1995/03/21 10:39:06 adam
119 # Diagnostic error message displayed with tkerror.
121 # Revision 1.10 1995/03/20 15:24:06 adam
122 # Diagnostic records saved on searchResponse.
124 # Revision 1.9 1995/03/17 18:26:16 adam
125 # Non-blocking i/o used now. Database names popup as cascade items.
127 # Revision 1.8 1995/03/17 15:45:00 adam
128 # Improved target/database setup.
130 # Revision 1.7 1995/03/16 17:54:03 adam
131 # Minor changes really.
133 # Revision 1.6 1995/03/15 19:10:20 adam
134 # Database setup in protocol-setup (rather target setup).
136 # Revision 1.5 1995/03/15 13:59:23 adam
139 # Revision 1.4 1995/03/14 17:32:29 adam
140 # Presentation of full Marc record in popup window.
142 # Revision 1.3 1995/03/12 19:31:52 adam
143 # Pattern matching implemented when retrieving MARC records. More
144 # diagnostic functions.
146 # Revision 1.2 1995/03/10 18:00:15 adam
147 # Actual presentation in line-by-line format. RPN query support.
149 # Revision 1.1 1995/03/09 16:15:07 adam
150 # First presentRequest attempts. Hot-target list.
159 set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} z39v2}
161 set settingsChanged 0
172 set queryTypes {Simple}
173 set queryButtons { { {I 0} {I 1} {I 2} } }
174 set queryInfo { { {Title {1=4 4=1}} {Author {1=1}} \
175 {Subject {1=21}} {Any {1=1016}} } }
181 proc read-formats {} {
182 global displayFormats
183 set formats [glob -nocomplain formats/*.tcl]
186 set l [expr [string length $f] - 5]
187 lappend displayFormats [string range $f 8 $l]
195 .data.record configure -wrap $m
198 proc set-display-format {f} {
208 .bot.a.status configure -text "Reformatting"
211 add-title-lines 0 10000 1
213 .bot.a.status configure -text "Ready"
217 proc initBindings {} {
220 bind $w <Double-1> {}
221 bind $w <Triple-1> {}
222 bind $w <B1-Motion> {}
224 bind $w <Shift-B1-Motion> {}
226 bind $w <B2-Motion> {}
227 bind $w <Any-KeyPress> {}
229 bind $w <BackSpace> {}
231 bind $w <Control-h> {}
232 bind $w <Control-d> {}
233 bind $w <Control-v> {}
236 bind $w <B1-Motion> {}
237 bind $w <Shift-B1-Motion> {}
242 proc post-menu {wbutton wmenu} {
245 $wmenu post [winfo rootx $wbutton] \
246 [expr [winfo rooty $wbutton]+[winfo height $wbutton]]
251 global windowGeometry
252 set windowGeometry($w) [wm geometry $w]
255 global windowGeometry
258 if {[info exists windowGeometry($w)]} {
259 set g $windowGeometry($w)
264 bind $w <Destroy> [list destroyGW $w]
267 if {[file readable "clientrc.tcl"]} {
268 source "clientrc.tcl"
271 if {[file readable "clientg.tcl"]} {
275 set queryButtonsFind [lindex $queryButtons 0]
276 set queryInfoFind [lindex $queryInfo 0]
278 proc top-down-window {w} {
279 frame $w.top -relief raised -border 1
280 frame $w.bot -relief raised -border 1
282 pack $w.top -side top -fill both -expand yes
283 pack $w.bot -fill both
286 proc top-down-ok-cancel {w ok-action g} {
287 frame $w.bot.left -relief sunken -border 1
288 pack $w.bot.left -side left -expand yes -ipadx 2 -ipady 2 -padx 5 -pady 5
289 button $w.bot.left.ok -width 6 -text {Ok} \
290 -command ${ok-action}
291 pack $w.bot.left.ok -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3
292 button $w.bot.cancel -width 6 -text {Cancel} \
293 -command [list destroy $w]
294 pack $w.bot.cancel -side left -expand yes
302 proc bottom-buttons {w buttonList g} {
304 set l [llength $buttonList]
306 frame $w.bot.$i -relief sunken -border 1
307 pack $w.bot.$i -side left -expand yes -padx 5 -pady 5
308 button $w.bot.$i.ok -text [lindex $buttonList $i] \
309 -command [lindex $buttonList [expr $i+1]]
310 pack $w.bot.$i.ok -expand yes -ipadx 3 -ipady 2 -padx 3 -pady 3 -side left
314 button $w.bot.$i -text [lindex $buttonList $i] \
315 -command [lindex $buttonList [expr $i+1]]
316 pack $w.bot.$i -expand yes -ipadx 2 -ipady 2 -padx 3 -pady 3 -side left
326 proc cancel-operation {} {
332 show-status Canceling 0 {}
336 proc show-target {target} {
337 .bot.a.target configure -text "$target"
340 proc show-logo {v1} {
347 .bot.logo configure -bitmap @book${v1}
348 after 140 [list show-logo $v1]
352 .bot.logo configure -bitmap @book1
361 proc show-status {status b sb} {
368 .bot.a.status configure -text "$status"
370 if {$busy == 0} {set busy 1}
378 .top.service configure -state normal
379 .mid.search configure -state normal
381 .mid.scan configure -state normal
383 if {$setOffset > 0 && $setOffset <= $setMax} {
384 .top.service.m enable 1
385 .mid.present configure -state normal
387 .top.service.m disable 1
389 if {[winfo exists .scan-window]} {
390 .scan-window.bot.2 configure -state normal
391 .scan-window.bot.4 configure -state normal
395 .top.service configure -state disabled
396 .mid.search configure -state disabled
397 .mid.scan configure -state disabled
398 .mid.present configure -state disabled
400 if {[winfo exists .scan-window]} {
401 .scan-window.bot.2 configure -state disabled
402 .scan-window.bot.4 configure -state disabled
408 proc show-message {msg} {
409 .bot.a.message configure -text "$msg"
412 proc insertWithTags {w text args} {
413 set start [$w index insert]
414 $w insert insert $text
415 foreach tag [$w tag names $start] {
416 $w tag remove $tag $start insert
419 $w tag add $i $start insert
423 proc popup-license {} {
427 wm title $w "License"
433 text $w.top.t -width 80 -height 10 -wrap word \
434 -yscrollcommand [list $w.top.s set]
435 scrollbar $w.top.s -command [list $w.top.t yview]
437 pack $w.top.s -side right -fill y
438 pack $w.top.t -expand yes -fill both
440 set f [open "LICENSE" r]
441 while {[gets $f buf] != -1} {
442 $w.top.t insert end $buf
443 $w.top.t insert end "\n"
446 bottom-buttons $w [list {Close} [list destroy $w]] 1
449 proc about-target {} {
450 set w .about-target-w
455 wm title $w "About target"
458 frame $w.top.a -relief ridge -border 2
459 frame $w.top.p -relief ridge -border 2
461 pack $w.top.a $w.top.p -side top -fill x
463 label $w.top.a.about -text "About"
464 label $w.top.a.irtcl -text $hostid \
465 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
466 pack $w.top.a.about $w.top.a.irtcl -side top
468 set i [z39 targetImplementationName]
469 label $w.top.p.in -text "Implementation name: $i"
470 set i [z39 targetImplementationId]
471 label $w.top.p.ii -text "Implementation id: $i"
472 set i [z39 targetImplementationVersion]
473 label $w.top.p.iv -text "Implementation version: $i"
475 label $w.top.p.op -text "Protocol options: $i"
477 pack $w.top.p.in $w.top.p.ii $w.top.p.iv $w.top.p.op -side top -anchor nw
479 bottom-buttons $w [list {Close} [list destroy $w]] 1
482 proc about-origin-logo {n} {
483 set w .about-origin-w
484 if {![winfo exists $w]} {
491 $w.top.a.logo configure -bitmap @book$n
492 after 140 [list about-origin-logo $n]
495 proc about-origin {} {
496 set w .about-origin-w
498 if {[winfo exists $w]} {
503 wm title $w "About IrTcl"
507 frame $w.top.a -relief ridge -border 2
508 frame $w.top.p -relief ridge -border 2
510 pack $w.top.a $w.top.p -side top -fill x
512 label $w.top.a.irtcl -text "IrTcl" \
513 -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
514 label $w.top.a.logo -bitmap @book1
515 pack $w.top.a.irtcl $w.top.a.logo -side left -expand yes
517 set i [z39 implementationName]
518 label $w.top.p.in -text "Implementation name: $i"
519 set i [z39 implementationId]
520 label $w.top.p.ii -text "Implementation id: $i"
521 set i [z39 implementationVersion]
522 label $w.top.p.iv -text "Implementation version: $i"
524 pack $w.top.p.in $w.top.p.ii $w.top.p.iv -side top -anchor nw
527 bottom-buttons $w [list {Close} [list destroy $w] \
528 {License} [list popup-license]] 0
531 proc popup-marc {sno no b df} {
533 global displayFormats
536 if {[z39.$sno type $no] != "DB"} {
540 set w .full-marc-$fullMarcSeq
547 if {[winfo exists $w]} {
555 frame $w.top -relief raised -border 1
556 frame $w.bot -relief raised -border 1
558 pack $w.top -side top -fill both -expand yes
559 pack $w.bot -fill both
561 text $w.top.record -width 60 -height 5 -wrap word \
562 -yscrollcommand [list $w.top.s set]
563 scrollbar $w.top.s -command [list $w.top.record yview]
565 if {[tk colormodel .] == "color"} {
566 $w.top.record tag configure marc-tag -foreground blue
567 $w.top.record tag configure marc-id -foreground red
569 $w.top.record tag configure marc-tag -foreground black
570 $w.top.record tag configure marc-id -foreground black
572 $w.top.record tag configure marc-data -foreground black
575 $w.top.record delete 0.0 end
576 set recordType [z39.$sno recordType $no]
577 wm title $w "$recordType record #$no"
579 set ffunc [lindex $displayFormats $df]
580 set ffunc "display-$ffunc"
582 $ffunc $sno $no $w.top.record 0
585 bind $w.top.record <Return> {destroy .full-marc}
587 pack $w.top.s -side right -fill y
588 pack $w.top.record -expand yes -fill both
591 bottom-buttons $w [list \
592 {Close} [list destroy $w]] 0
594 bottom-buttons $w [list \
595 {Close} [list destroy $w] \
596 {Duplicate} [list popup-marc $sno $no 1 0]] 0
597 menubutton $w.bot.formats -text "Format" -menu $w.bot.formats.m
598 menu $w.bot.formats.m
600 foreach f $displayFormats {
601 $w.bot.formats.m add radiobutton -label $f \
602 -variable popupMarcdf -value $i \
603 -command [list display-$f $sno $no $w.top.record 0]
606 pack $w.bot.formats -expand yes -ipadx 2 -ipady 2 \
607 -padx 3 -pady 3 -side left
611 foreach f $displayFormats {
612 $w.bot.formats.m entryconfigure $i \
613 -command [list display-$f $sno $no $w.top.record 0]
619 proc update-target-hotlist {target} {
622 set len [llength $hotTargets]
624 .top.target.m delete 6 [expr 6+[llength $hotTargets]]
626 set indx [lsearch $hotTargets $target]
628 set hotTargets [lreplace $hotTargets $indx $indx]
630 set hotTargets [linsert $hotTargets 0 $target]
634 proc set-target-hotlist {} {
638 foreach target $hotTargets {
639 .top.target.m add command -label "$i $target" -command \
640 [list reopen-target $target {}]
648 proc reopen-target {target base} {
650 open-target $target $base
651 update-target-hotlist $target
654 proc define-target-action {} {
657 set target [.target-define.top.target.entry get]
661 update-target-hotlist $target
662 foreach n [array names profile] {
668 set seq [lindex $profile(Default) 12]
670 set profile($target) $profile(Default)
671 set profile(Default) [lreplace $profile(Default) 12 12 [incr seq]]
673 protocol-setup $target
674 destroy .target-define
677 proc fail-response {target} {
679 tkerror "Target connection closed or protocol error"
682 proc connect-response {target} {
683 puts "connect-response"
688 proc open-target {target base} {
693 z39 comstack [lindex $profile($target) 6]
694 z39 idAuthentication [lindex $profile($target) 3]
695 z39 maximumRecordSize [lindex $profile($target) 4]
696 z39 preferredMessageSize [lindex $profile($target) 5]
697 puts -nonewline "maximumRecordSize="
698 puts [z39 maximumRecordSize]
699 puts -nonewline "preferredMessageSize="
700 puts [z39 preferredMessageSize]
701 show-status {Connecting} 0 0
703 z39 databaseNames [lindex [lindex $profile($target) 7] 0]
705 z39 databaseNames $base
707 z39 failback [list fail-response $target]
708 z39 callback [list connect-response $target]
709 z39 connect [lindex $profile($target) 1]:[lindex $profile($target) 2]
710 # z39 options search present scan namedResultSets triggerResourceCtrl
711 show-status {Connecting} 1 {}
713 .top.target.m disable 0
714 .top.target.m enable 1
715 .top.target.m enable 2
718 proc close-target {} {
725 .bot.a.set configure -text ""
729 show-status {Not connected} 0 0
732 .top.target.m disable 1
733 .top.target.m disable 2
734 .top.target.m enable 0
737 proc load-set-action {} {
741 ir-set z39.$setNo z39
743 set fname [.load-set.top.filename.entry get]
746 show-status {Loading} 1 {}
748 z39.$setNo loadFile $fname
750 set no [z39.$setNo numberOfRecordsReturned]
751 add-title-lines $setNo $no 1
753 set l [format "%-4d %7d" $setNo $no]
754 .top.rset.m add command -label $l \
755 -command [list add-title-lines $setNo 10000 1]
756 show-status {Ready} 0 {}
768 frame $w.top.filename
769 pack $w.top.filename -side top -anchor e -pady 2
771 entry-fields $w.top {filename} \
773 {load-set-action} {destroy .load-set}
775 top-down-ok-cancel $w {load-set-action} 1
779 proc init-request {} {
787 z39 callback {init-response}
788 show-status {Initializing} 1 {}
792 proc init-response {} {
800 if {![z39 initResult]} {
801 show-status {Ready} 0 1
802 set u [z39 userInformationField]
804 tkerror "Connection rejected by target: $u"
806 if {[lsearch [z39 options] scan] >= 0} {
811 show-status {Ready} 0 1
815 proc search-request {} {
825 if {$searchEnable == 0} {
828 set query [index-query]
833 ir-set z39.$setNo z39
834 z39.$setNo preferredRecordSyntax SUTRS
836 if {[lindex $profile($target) 10] == 1} {
837 z39.$setNo setName $setNo
838 puts "setName=${setNo}"
840 z39.$setNo setName Default
841 puts "setName=Default"
843 if {[lindex $profile($target) 8] == 1} {
844 z39.$setNo queryType rpn
846 if {[lindex $profile($target) 9] == 1} {
847 z39.$setNo queryType ccl
849 z39 callback {search-response}
850 z39.$setNo search $query
851 show-status {Searching} 1 0
854 proc scan-copy {y entry} {
856 set no [$w.top.list nearest $y]
858 .lines.$entry.e delete 0 end
859 .lines.$entry.e insert 0 [string range [$w.top.list get $no] 8 end]
862 proc scan-request {} {
870 global queryButtonsFind
877 set b [lindex $queryButtonsFind $curIndexEntry]
879 foreach a [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end] {
880 set attr "@attr $a $attr"
882 set title [lindex [lindex $queryInfoFind [lindex $b 1]] 0]
885 if {![winfo exists $w]} {
892 entry $w.top.entry -relief sunken
893 pack $w.top.entry -fill x -padx 4 -pady 2
894 bind $w.top.entry <KeyRelease> [list scan-term-h $attr]
896 listbox $w.top.list -yscrollcommand [list $w.top.scroll set] \
898 scrollbar $w.top.scroll -orient vertical -border 1
899 pack $w.top.list -side left -fill both -expand yes
900 pack $w.top.scroll -side right -fill y
901 $w.top.scroll config -command [list $w.top.list yview]
903 listbox $w.top.list -font fixed -geometry 60x14
904 pack $w.top.list -side left -fill both -expand yes
907 bottom-buttons $w [list {Close} [list destroy $w] \
908 {Up} [list scan-up $attr] \
909 {Down} [list scan-down $attr]] 0
910 bind $w.top.list <Up> [list scan-up $attr]
911 bind $w.top.list <Down> [list scan-down $attr]
913 bind $w.top.list <Double-Button-1> [list scan-copy %y $curIndexEntry]
914 wm title $w "Scan $title"
916 z39 callback [list scan-response $attr 0 35]
917 z39.scan numberOfTermsRequested 5
918 z39.scan preferredPositionInResponse 1
919 z39.scan scan "${attr} 0"
921 show-status {Scanning} 1 0
924 proc scan-term-h {attr} {
932 set nScanTerm [$w.top.entry get]
933 if {$nScanTerm == $scanTerm} {
936 set scanTerm $nScanTerm
937 z39 callback [list scan-response $attr 0 35]
938 z39.scan numberOfTermsRequested 5
939 z39.scan preferredPositionInResponse 1
940 puts "${attr} \{${scanTerm}\}"
941 if {$scanTerm == ""} {
942 z39.scan scan "${attr} 0"
944 z39.scan scan "${attr} \{${scanTerm}\}"
946 show-status {Scanning} 1 0
949 proc scan-response {attr start toget} {
955 puts "In scan-response"
956 set m [z39.scan numberOfEntriesReturned]
962 if {![winfo exists .scan-window]} {
963 show-status {Ready} 0 1
967 set nScanTerm [$w.top.entry get]
968 if {$nScanTerm != $scanTerm} {
969 z39 callback [list scan-response $attr 0 35]
970 z39.scan numberOfTermsRequested 5
971 z39.scan preferredPositionInResponse 1
972 set scanTerm $nScanTerm
973 puts "${attr} \{${scanTerm}\}"
974 if {$scanTerm == ""} {
975 z39.scan scan "${attr} 0"
977 z39.scan scan "${attr} \{${scanTerm}\}"
979 show-status {Scanning} 1 0
982 set status [z39.scan scanStatus]
985 show-status {Ready} 0 1
990 for {set i 0} {$i < $m} {incr i} {
991 set term [lindex [z39.scan scanLine $i] 1]
992 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
993 $w.top.list insert $i "$nostr $term"
996 $w.top.list yview $scanView
998 $w.top.list delete $start end
999 for {set i 0} {$i < $m} {incr i} {
1000 set term [lindex [z39.scan scanLine $i] 1]
1001 set nostr [format " %-6d" [lindex [z39.scan scanLine $i] 2]]
1002 $w.top.list insert end "$nostr $term"
1006 show-status {Ready} 0 1
1010 if {$toget > 0 && $m > 1 && $m < $toget} {
1011 set ntoget [expr $toget - $m + 1]
1013 z39 callback [list scan-response $attr [expr $start + $m - 1] $ntoget]
1015 puts "down continue: $q"
1017 z39.scan numberOfTermsRequested 10
1019 z39.scan numberOfTermsRequested $ntoget
1021 z39.scan preferredPositionInResponse 1
1022 puts "${attr} \{$q\}"
1023 z39.scan scan "${attr} \{$q\}"
1026 if {$toget < 0 && $m > 1 && $m < [expr - $toget]} {
1027 set ntoget [expr - $toget - $m]
1029 z39 callback [list scan-response $attr 0 -$ntoget]
1030 set q [string range [$w.top.list get 0] 8 end]
1031 puts "up continue: $q"
1033 z39.scan numberOfTermsRequested 10
1034 z39.scan preferredPositionInResponse 11
1036 z39.scan numberOfTermsRequested $ntoget
1037 z39.scan preferredPositionInResponse [incr ntoget]
1039 puts "${attr} \{$q\}"
1040 z39.scan scan "${attr} \{$q\}"
1043 show-status {Ready} 0 1
1046 proc scan-down {attr} {
1050 set scanView [expr $scanView + 5]
1051 set s [$w.top.list size]
1052 if {$scanView > $s} {
1053 z39 callback [list scan-response $attr [expr $s - 1] 25]
1054 set q [string range [$w.top.list get [expr $s - 1]] 8 end]
1056 z39.scan numberOfTermsRequested 10
1057 z39.scan preferredPositionInResponse 1
1058 show-status {Scanning} 1 0
1059 puts "${attr} \{$q\}"
1060 z39.scan scan "${attr} \{$q\}"
1063 $w.top.list yview $scanView
1066 proc scan-up {attr} {
1070 set scanView [expr $scanView - 5]
1071 if {$scanView < 0} {
1072 z39 callback [list scan-response $attr 0 -25]
1073 set q [string range [$w.top.list get 0] 8 end]
1075 z39.scan numberOfTermsRequested 10
1076 z39.scan preferredPositionInResponse 11
1077 show-status {Scanning} 1 0
1078 z39.scan scan "${attr} \{$q\}"
1081 $w.top.list yview $scanView
1084 proc search-response {} {
1091 puts "In search-response"
1093 set setMax [z39.$setNo resultCount]
1094 show-message "${setMax} hits"
1095 set l [format "%-4d %7d" $setNo $setMax]
1096 .top.rset.m add command -label $l \
1097 -command [list add-title-lines $setNo 10000 1]
1099 show-status {Ready} 0 1
1100 set status [z39.$setNo responseStatus]
1101 if {[lindex $status 0] == "NSD"} {
1102 set code [lindex $status 1]
1103 set msg [lindex $status 2]
1104 set addinfo [lindex $status 3]
1105 tkerror "NSD$code: $msg: $addinfo"
1113 show-status {Ready} 0 1
1118 z39 callback {present-response}
1119 z39.$setNo present $setOffset 1
1120 show-status {Retrieving} 1 0
1123 proc present-more {number} {
1128 puts "setOffset=$setOffset"
1134 set max [z39.$setNo resultCount]
1135 if {$max <= $setOffset} {
1137 puts "setOffset=$setOffset"
1140 if {$number == ""} {
1144 if {$setMax > $max} {
1148 z39 callback {present-response}
1150 set toGet [expr $setMax - $setOffset + 1]
1157 z39.$setNo present $setOffset $toGet
1158 show-status {Retrieving} 1 0
1161 proc init-title-lines {} {
1162 .data.record delete 0.0 end
1165 proc title-press {y setno} {
1166 show-full-marc $setno [expr 1 + [.data.list nearest $y]] 0
1169 proc add-title-lines {setno no offset} {
1170 global displayFormats
1171 global displayFormat
1175 set setno $lastSetNo
1177 set lastSetNo $setno
1180 .bot.a.set configure -text $setno
1181 .data.record delete 0.0 end
1183 set ffunc [lindex $displayFormats $displayFormat]
1184 set ffunc "display-$ffunc"
1185 for {set i 0} {$i < $no} {incr i} {
1186 set o [expr $i + $offset]
1187 set type [z39.$setno type $o]
1191 .data.record tag bind r$o <Any-Enter> {}
1192 .data.record tag bind r$o <Any-Leave> {}
1193 set insert0 [.data.record index insert]
1194 $ffunc $setno $o .data.record 1
1195 .data.record tag add r$o $insert0 insert
1196 .data.record tag bind r$o <1> \
1197 [list popup-marc $setno $o 0 0]
1202 proc present-response {} {
1208 puts "In present-response"
1209 set no [z39.$setNo numberOfRecordsReturned]
1210 puts "Returned $no records, setOffset $setOffset"
1211 add-title-lines $setNo $no $setOffset
1212 set setOffset [expr $setOffset + $no]
1213 set status [z39.$setNo responseStatus]
1214 if {[lindex $status 0] == "NSD"} {
1215 show-status {Ready} 0 1
1216 set code [lindex $status 1]
1217 set msg [lindex $status 2]
1218 set addinfo [lindex $status 3]
1219 tkerror "NSD$code: $msg: $addinfo"
1223 show-status {Ready} 0 1
1227 if {$no > 0 && $setOffset <= $setMax} {
1228 puts "present-request from ${setOffset}"
1229 set toGet [expr $setMax - $setOffset + 1]
1233 z39.$setNo present $setOffset $toGet
1235 show-status {Ready} 0 1
1239 proc left-cursor {w} {
1240 set i [$w index insert]
1247 proc right-cursor {w} {
1248 set i [$w index insert]
1253 proc bind-fields {list returnAction escapeAction} {
1254 set max [expr [llength $list]-1]
1255 for {set i 0} {$i < $max} {incr i} {
1256 bind [lindex $list $i] <Return> $returnAction
1257 bind [lindex $list $i] <Escape> $escapeAction
1258 bind [lindex $list $i] <Tab> [list focus [lindex $list [expr $i+1]]]
1259 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1260 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1262 bind [lindex $list $i] <Return> $returnAction
1263 bind [lindex $list $i] <Escape> $escapeAction
1264 bind [lindex $list $i] <Tab> [list focus [lindex $list 0]]
1265 bind [lindex $list $i] <Left> [list left-cursor [lindex $list $i]]
1266 bind [lindex $list $i] <Right> [list right-cursor [lindex $list $i]]
1267 focus [lindex $list 0]
1270 proc entry-fields {parent list tlist returnAction escapeAction} {
1273 foreach field $list {
1274 set label ${parent}.${field}.label
1275 set entry ${parent}.${field}.entry
1276 label $label -text [lindex $tlist $i] -anchor e
1277 entry $entry -width 32 -relief sunken
1278 pack $label -side left
1279 pack $entry -side right
1280 lappend alist $entry
1283 bind-fields $alist $returnAction $escapeAction
1286 proc define-target-dialog {} {
1287 set w .target-define
1293 pack $w.top.target \
1294 -side top -anchor e -pady 2
1295 entry-fields $w.top {target} \
1297 {define-target-action} {destroy .target-define}
1298 top-down-ok-cancel $w {define-target-action} 1
1301 proc protocol-setup-delete {target} {
1304 set a [alert "Are you sure you want to delete the target \
1305 definition $target ?"]
1307 set wno [lindex $profile($target) 12]
1310 unset profile($target)
1315 proc protocol-setup-action {target} {
1318 global protocolRadioType
1319 global settingsChanged
1322 global ResultSetCheck
1324 set wno [lindex $profile($target) 12]
1328 set settingsChanged 1
1329 set len [$w.top.databases.list size]
1330 for {set i 0} {$i < $len} {incr i} {
1331 lappend b [$w.top.databases.list get $i]
1333 set profile($target) [list [$w.top.description.entry get] \
1334 [$w.top.host.entry get] \
1335 [$w.top.port.entry get] \
1336 [$w.top.idAuthentication.entry get] \
1337 [$w.top.maximumRecordSize.entry get] \
1338 [$w.top.preferredMessageSize.entry get] \
1344 $protocolRadioType \
1348 puts $profile($target)
1352 proc place-force {window parent} {
1353 set g [wm geometry $parent]
1355 set p1 [string first + $g]
1356 set p2 [string last + $g]
1358 set x [expr 40+[string range $g [expr $p1 +1] [expr $p2 -1]]]
1359 set y [expr 60+[string range $g [expr $p2 +1] end]]
1360 wm geometry $window +${x}+${y}
1363 proc add-database-action {target} {
1366 set wno [lindex $profile($target) 12]
1369 $w.top.databases.list insert end \
1370 [.database-select.top.database.entry get]
1371 destroy .database-select
1374 proc add-database {target} {
1377 set w .database-select
1379 set oldFocus [focus]
1382 set wno [lindex $profile($target) 12]
1383 place-force $w .setup-${wno}
1387 frame $w.top.database
1389 pack $w.top.database -side top -anchor e -pady 2
1391 entry-fields $w.top {database} \
1392 {{Database to add:}} \
1393 [list add-database-action $target] {destroy .database-select}
1395 top-down-ok-cancel $w [list add-database-action $target] 1
1399 proc delete-database {target} {
1402 set wno [lindex $profile($target) 12]
1405 foreach i [$w.top.databases.list curselection] {
1406 set b [$w.top.databases.list get $i]
1409 set a [alert "Are you sure you want to remove the database(s)${l}?"]
1411 foreach i [lsort -decreasing \
1412 [$w.top.databases.list curselection]] {
1413 $w.top.databases.list delete $i
1418 proc protocol-setup {target} {
1421 global protocolRadioType
1424 global ResultSetCheck
1426 set wno [lindex $profile($target) 12]
1431 wm title $w "Setup $target"
1435 if {$target == ""} {
1439 puts $profile($target)
1443 frame $w.top.description
1444 frame $w.top.idAuthentication
1445 frame $w.top.maximumRecordSize
1446 frame $w.top.preferredMessageSize
1447 frame $w.top.cs-type -relief ridge -border 2
1448 frame $w.top.protocol -relief ridge -border 2
1449 frame $w.top.query -relief ridge -border 2
1450 frame $w.top.databases -relief ridge -border 2
1452 # Maximum/preferred/idAuth ...
1453 pack $w.top.description $w.top.host $w.top.port \
1454 $w.top.idAuthentication $w.top.maximumRecordSize \
1455 $w.top.preferredMessageSize -side top -anchor e -pady 2
1457 entry-fields $w.top {description host port idAuthentication \
1458 maximumRecordSize preferredMessageSize} \
1459 {{Description:} {Host:} {Port:} {Id Authentication:} \
1460 {Maximum Record Size:} {Preferred Message Size:}} \
1461 [list protocol-setup-action $target] [list destroy $w]
1463 foreach sub {description host port idAuthentication \
1464 maximumRecordSize preferredMessageSize} {
1466 bind $w.top.$sub.entry <Control-a> [list add-database $target]
1467 bind $w.top.$sub.entry <Control-d> [list delete-database $target]
1469 $w.top.description.entry insert 0 [lindex $profile($target) 0]
1470 $w.top.host.entry insert 0 [lindex $profile($target) 1]
1471 $w.top.port.entry insert 0 [lindex $profile($target) 2]
1472 $w.top.idAuthentication.entry insert 0 [lindex $profile($target) 3]
1473 $w.top.maximumRecordSize.entry insert 0 [lindex $profile($target) 4]
1474 $w.top.preferredMessageSize.entry insert 0 [lindex $profile($target) 5]
1475 set csRadioType [lindex $profile($target) 6]
1476 set RPNCheck [lindex $profile($target) 8]
1477 set CCLCheck [lindex $profile($target) 9]
1478 set ResultSetCheck [lindex $profile($target) 10]
1479 set protocolRadioType [lindex $profile($target) 11]
1480 if {$protocolRadioType == ""} {
1481 set protocolRadioType z39v2
1485 pack $w.top.databases -side left -pady 4 -padx 4 -expand yes -fill both
1487 label $w.top.databases.label -text "Databases"
1488 button $w.top.databases.add -text "Add" \
1489 -command [list add-database $target]
1490 button $w.top.databases.delete -text "Delete" \
1491 -command [list delete-database $target]
1492 listbox $w.top.databases.list -geometry 20x6 \
1493 -yscrollcommand "$w.top.databases.scroll set"
1494 scrollbar $w.top.databases.scroll -orient vertical -border 1
1495 pack $w.top.databases.label -side top -fill x \
1497 pack $w.top.databases.add $w.top.databases.delete -side top -fill x \
1499 pack $w.top.databases.list -side left -fill both -expand yes \
1501 pack $w.top.databases.scroll -side right -fill y \
1503 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1505 foreach b [lindex $profile($target) 7] {
1506 $w.top.databases.list insert end $b
1510 pack $w.top.cs-type -pady 4 -padx 4 -side top -fill x
1512 label $w.top.cs-type.label -text "Transport"
1513 radiobutton $w.top.cs-type.tcpip -text "TCP/IP" -anchor w \
1514 -command {puts tcp/ip} -variable csRadioType -value tcpip
1515 radiobutton $w.top.cs-type.mosi -text "MOSI" -anchor w\
1516 -command {puts mosi} -variable csRadioType -value mosi
1518 pack $w.top.cs-type.label $w.top.cs-type.tcpip $w.top.cs-type.mosi \
1519 -padx 4 -side top -fill x
1522 pack $w.top.protocol -pady 4 -padx 4 -side top -fill x
1524 label $w.top.protocol.label -text "Protocol"
1525 radiobutton $w.top.protocol.z39v2 -text "Z39.50" -anchor w \
1526 -command {puts z39v2} -variable protocolRadioType -value z39v2
1527 radiobutton $w.top.protocol.sr -text "SR" -anchor w \
1528 -command {puts sr} -variable protocolRadioType -value sr
1530 pack $w.top.protocol.label $w.top.protocol.z39v2 $w.top.protocol.sr \
1531 -padx 4 -side top -fill x
1534 pack $w.top.query -pady 4 -padx 4 -side top -fill x
1536 label $w.top.query.label -text "Query support"
1537 checkbutton $w.top.query.c1 -text "RPN query" -anchor w -variable RPNCheck
1538 checkbutton $w.top.query.c2 -text "CCL query" -anchor w -variable CCLCheck
1539 checkbutton $w.top.query.c3 -text "Result sets" -anchor w -variable ResultSetCheck
1541 pack $w.top.query.label -side top
1542 pack $w.top.query.c1 $w.top.query.c2 $w.top.query.c3 \
1543 -padx 4 -side top -fill x
1546 bottom-buttons $w [list {Ok} [list protocol-setup-action $target] \
1547 {Delete} [list protocol-setup-delete $target] \
1548 {Cancel} [list destroy $w]] 0
1551 proc database-select-action {} {
1552 set w .database-select.top
1554 foreach indx [$w.databases.list curselection] {
1555 lappend b [$w.databases.list get $indx]
1558 z39 databaseNames $b
1560 destroy .database-select
1563 proc database-select {} {
1564 set w .database-select
1574 frame $w.top.databases -relief ridge -border 2
1576 pack $w.top.databases -side left -pady 6 -padx 6 -expand yes -fill x
1578 label $w.top.databases.label -text "List"
1579 listbox $w.top.databases.list -geometry 20x6 \
1580 -yscrollcommand "$w.top.databases.scroll set"
1581 scrollbar $w.top.databases.scroll -orient vertical -border 1
1582 pack $w.top.databases.label -side top -fill x \
1584 pack $w.top.databases.list -side left -fill both -expand yes \
1586 pack $w.top.databases.scroll -side right -fill y \
1588 $w.top.databases.scroll config -command "$w.top.databases.list yview"
1590 foreach b [lindex $profile($hostid) 7] {
1591 $w.top.databases.list insert end $b
1593 top-down-ok-cancel $w {database-select-action} 1
1596 proc cascade-target-list {} {
1599 foreach sub [winfo children .top.target.m.clist] {
1602 .top.target.m.clist delete 0 last
1603 foreach n [array names profile] {
1604 if {$n != "Default"} {
1605 set nl [lindex $profile($n) 12]
1606 if {[llength [lindex $profile($n) 7]] > 1} {
1607 .top.target.m.clist add cascade -label $n \
1608 -menu .top.target.m.clist.$nl
1609 menu .top.target.m.clist.$nl
1610 foreach b [lindex $profile($n) 7] {
1611 .top.target.m.clist.$nl add command -label $b \
1612 -command [list reopen-target $n $b]
1615 .top.target.m.clist add command -label $n \
1616 -command [list reopen-target $n {}]
1620 .top.target.m.slist delete 0 last
1621 foreach n [array names profile] {
1622 if {$n != "Default"} {
1623 .top.target.m.slist add command -label $n \
1624 -command [list protocol-setup $n]
1629 proc query-select {i} {
1630 global queryButtonsFind
1631 global queryInfoFind
1635 set queryInfoFind [lindex $queryInfo $i]
1636 set queryButtonsFind [lindex $queryButtons $i]
1638 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
1641 proc query-new-action {} {
1645 global settingsChanged
1647 set settingsChanged 1
1648 lappend queryTypes [.query-new.top.index.entry get]
1649 lappend queryButtons {}
1650 lappend queryInfo {}
1664 -side top -anchor e -pady 2
1665 entry-fields $w.top index \
1667 query-new-action {destroy .query-new}
1668 top-down-ok-cancel $w query-new-action 1
1671 proc query-delete-action {queryNo} {
1675 global settingsChanged
1677 set settingsChanged 1
1679 set queryTypes [lreplace $queryTypes $queryNo $queryNo]
1680 set queryButtons [lreplace $queryButtons $queryNo $queryNo]
1681 set queryInfo [lreplace $queryInfo $queryNo $queryNo]
1682 destroy .query-delete
1686 proc query-delete {queryNo} {
1694 set n [lindex $queryTypes $queryNo]
1696 label $w.top.warning -bitmap warning
1697 message $w.top.quest -text "Are you sure you want to delete the \
1698 query type $n ?" -aspect 200
1699 pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
1700 bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
1701 {Cancel} [list destroy $w]] 1
1704 proc cascade-query-list {} {
1706 set w .top.options.m.query
1709 $w.slist delete 0 last
1710 foreach n $queryTypes {
1711 $w.slist add command -label $n -command [list query-setup $i]
1716 $w.clist delete 0 last
1717 foreach n $queryTypes {
1718 $w.clist add command -label $n -command [list query-select $i]
1722 $w.dlist delete 0 last
1723 foreach n $queryTypes {
1724 $w.dlist add command -label $n -command [list query-delete $i]
1729 proc save-geometry {} {
1730 global windowGeometry
1733 global displayFormat
1736 set windowGeometry(.) [wm geometry .]
1738 set f [open "clientg.tcl" w]
1740 puts $f "set hotTargets \{ $hotTargets \}"
1741 puts $f "set textWrap $textWrap"
1742 puts $f "set displayFormat $displayFormat"
1743 puts $f "set popupMarcdf $popupMarcdf"
1744 foreach n [array names windowGeometry] {
1745 puts -nonewline $f "set \{windowGeometry($n)\} \{"
1746 puts -nonewline $f $windowGeometry($n)
1752 proc save-settings {} {
1754 global settingsChanged
1759 set f [open "clientrc.tcl" w]
1760 puts $f "# Setup file"
1762 foreach n [array names profile] {
1763 puts -nonewline $f "set \{profile($n)\} \{"
1764 puts -nonewline $f $profile($n)
1767 puts -nonewline $f "set queryTypes \{"
1768 puts -nonewline $f $queryTypes
1771 puts -nonewline $f "set queryButtons \{"
1772 puts -nonewline $f $queryButtons
1775 puts -nonewline $f "set queryInfo \{"
1776 puts -nonewline $f $queryInfo
1779 set settingsChanged 0
1791 label $w.top.warning -bitmap warning
1792 message $w.top.message -text $ask -aspect 200 \
1793 -font -Adobe-Times-Medium-R-Normal-*-180-*
1795 pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
1798 top-down-ok-cancel $w {alert-action} 1
1802 proc alert-action {} {
1808 proc exit-action {} {
1809 global settingsChanged
1811 if {$settingsChanged} {
1812 set a [alert "you havent saved your settings. Do you wish to save?"]
1821 proc listbuttonaction {w name h user i} {
1822 $w configure -text [lindex $name 0]
1823 $h [lindex $name 1] $user $i
1826 proc listbuttonx {button no names handle user} {
1827 if {[winfo exists $button]} {
1828 $button configure -text [lindex [lindex $names $no] 0]
1829 ${button}.m delete 0 last
1831 menubutton $button -text [lindex [lindex $names $no] 0] \
1832 -width 10 -menu ${button}.m -relief raised -border 1
1836 foreach name $names {
1837 ${button}.m add command -label [lindex $name 0] \
1838 -command [list listbuttonaction ${button} $name \
1844 proc listbutton {button no names} {
1845 menubutton $button -text [lindex $names $no] -width 10 -menu ${button}.m \
1846 -relief raised -border 1
1848 foreach name $names {
1849 ${button}.m add command -label $name \
1850 -command [list ${button} configure -text $name]
1854 proc listbuttonv-action {button var names i} {
1857 set $var [lindex $names [expr $i+1]]
1858 $button configure -text [lindex $names $i]
1861 proc listbuttonv {button var names} {
1865 eval "set val $$var"
1866 set l [llength $names]
1867 for {set i 1} {$i < $l} {incr i 2} {
1868 if {$val == [lindex $names $i]} {
1870 set n [lindex $names $i]
1874 if {[winfo exists $button]} {
1875 $button configure -text $n
1878 menubutton $button -text $n -menu ${button}.m \
1879 -relief raised -border 1
1881 for {set i 0} {$i < $l} {incr i 2} {
1882 ${button}.m add command -label [lindex $names $i] \
1883 -command [list listbuttonv-action $button $var $names $i]
1887 proc query-add-index-action {queryNo} {
1891 global queryButtonsTmp
1893 set newI [.query-add-index.top.index.entry get]
1894 lappend queryInfoTmp [list $newI {}]
1895 $w.top.index.list insert end $newI
1896 destroy .query-add-index
1897 #destroy $w.top.lines
1898 #frame $w.top.lines -relief ridge -border 2
1899 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1900 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
1903 proc query-add-line {queryNo} {
1907 global queryButtonsTmp
1909 lappend queryButtonsTmp {I 0}
1911 #destroy $w.top.lines
1912 #frame $w.top.lines -relief ridge -border 2
1913 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1914 #pack $w.top.lines -side left -pady 6 -padx 6 -fill y
1917 proc query-del-line {queryNo} {
1921 global queryButtonsTmp
1923 set l [llength $queryButtonsTmp]
1928 set queryButtonsTmp [lreplace $queryButtonsTmp $l $l]
1929 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
1932 proc query-add-index {queryNo} {
1933 set w .query-add-index
1936 place-force $w .query-setup
1940 -side top -anchor e -pady 2
1941 entry-fields $w.top {index} \
1943 [list query-add-index-action $queryNo] [list destroy $w]
1944 top-down-ok-cancel $w [list query-add-index-action $queryNo] 1
1947 proc query-setup-action {queryNo} {
1950 global queryButtonsTmp
1952 global queryButtonsFind
1953 global queryInfoFind
1955 global settingsChanged
1957 set settingsChanged 1
1959 set queryInfo [lreplace $queryInfo $queryNo $queryNo \
1961 set queryButtons [lreplace $queryButtons $queryNo $queryNo \
1963 set queryInfoFind $queryInfoTmp
1964 set queryButtonsFind $queryButtonsTmp
1966 destroy .query-setup
1967 index-lines .lines 1 $queryButtonsFind $queryInfoFind activate-index
1970 proc activate-e-index {value no i} {
1971 global queryButtonsTmp
1972 global queryIndexTmp
1974 set queryButtonsTmp [lreplace $queryButtonsTmp $no $no [list I $i]]
1975 puts $queryButtonsTmp
1976 set queryIndexTmp $i
1979 proc activate-index {value no i} {
1980 global queryButtonsFind
1982 set queryButtonsFind [lreplace $queryButtonsFind $no $no [list I $i]]
1984 puts "queryButtonsFind $queryButtonsFind"
1987 proc update-attr {} {
1989 listbuttonv $w.top.relation.b relationTmpValue\
1990 {{None} 0 {Less than} 1 {Greater than or equal} 2 {Equal} 3 \
1991 {Greater than or equal} 4 {Greater than} 5 {Not equal} 6 \
1992 {Phonetic} 100 {Stem} 101 {Relevance} 102 {AlwaysMatches} 103}
1993 listbuttonv $w.top.position.b positionTmpValue {{None} 0 \
1994 {First in field} 1 {First in subfield} 2 {Any position in field} 3}
1995 listbuttonv $w.top.structure.b structureTmpValue {{None} 0 {Phrase} 1 \
1996 {Word} 2 {Key} 3 {Year} 4 {Date (norm)} 5 {Word list} 6 \
1997 {Date (un-norm)} 100 {Name (norm)} 101 {Date (un-norm)} 102 \
1998 {Structure} 103 {urx} 104 {free-form} 105 {doc-text} 106 \
1999 {local-number} 107 {string} 108 {numeric string} 109}
2000 listbuttonv $w.top.truncation.b truncationTmpValue {{Auto} 0 {Right} 1 \
2001 {Left} 2 {Left and right} 3 {No truncation} 100 \
2002 {Process #} 101 {Re-1} 102 {Re-2} 103}
2003 listbuttonv $w.top.completeness.b completenessTmpValue {{None} 0 \
2004 {Incomplete subfield} 1 {Complete subfield} 2 {Complete field} 3}
2007 proc use-attr {init} {
2019 {BNB card number} 10
2020 {BGF(sic) number} 11
2022 {Dewey classification} 13
2023 {UDC classification} 14
2024 {Bliss classification} 15
2026 {NLM call number} 17
2027 {NAL call number} 18
2028 {MOS call number} 19
2029 {Local classification} 20
2030 {Subject heading} 21
2032 {BDI-index-subject} 23
2036 {LC-subject-heading} 27
2037 {RVM-subject-heading} 28
2038 {Local subject index} 29
2040 {Date of publication} 31
2041 {Date of acquisition} 32
2043 {Title-collective} 34
2046 {Title-added-title-page} 37
2050 {Title-other-variant} 41
2052 {Title-abbreviated} 43
2056 {Subject-subdivision} 47
2057 {Number-natl-bibliography} 48
2058 {Number-legal-deposit} 49
2059 {Number-govt-publication} 50
2060 {Number-publisher-for-music} 51
2062 {Number-local-call} 53
2064 {Code-geographic-area} 55
2065 {Code-institution} 56
2067 {Name-geographic} 58
2068 {Place-publication} 59
2070 {Microform-generation} 61
2077 {Author-name-personal} 1004
2078 {Author-name-corporate} 1005
2079 {Author-name-conference} 1006
2080 {Identifier-standard} 1007
2081 {Subject-LC-children's} 1008
2082 {Subject-name-personal} 1009
2084 {Date/time added to database} 1011
2085 {Date/time last modified} 1012
2086 {Authority/format identifier} 1013
2088 {Concept-reference} 1015
2090 {Server choice} 1017
2092 {Record source} 1019
2095 {Geographic class} 1022
2099 {Related periodical} 1026
2100 {Report number} 1027
2102 {Thematic number} 1030
2103 {Material type} 1031
2111 set l [llength $attr]
2116 for {set i 0} {$i < $l} {incr i} {
2117 $w.top.use.list insert end [lindex $attr $i]
2119 if {$useTmpValue == [lindex $attr $i]} {
2124 $w.top.use.list select from $s
2125 $w.top.use.list select to $s
2130 $w.top.use.list yview $s
2132 set lno [lindex [$w.top.use.list curselection] 0]
2133 set i [expr $lno+$lno+1]
2134 set useTmpValue [lindex $attr $i]
2135 puts "useTmpValue=$useTmpValue"
2139 proc index-setup-action {oldAttr queryNo indexNo} {
2140 set attr [lindex $oldAttr 0]
2143 global relationTmpValue
2144 global structureTmpValue
2145 global truncationTmpValue
2146 global completenessTmpValue
2147 global positionTmpValue
2152 puts "index-setup-action"
2153 puts "queryNo $queryNo"
2154 puts "indexNo $indexNo"
2155 if {$useTmpValue > 0} {
2156 lappend attr "1=$useTmpValue"
2158 if {$relationTmpValue > 0} {
2159 lappend attr "2=$relationTmpValue"
2161 if {$positionTmpValue > 0} {
2162 lappend attr "3=$positionTmpValue"
2164 if {$structureTmpValue > 0} {
2165 lappend attr "4=$structureTmpValue"
2167 if {$truncationTmpValue > 0} {
2168 lappend attr "5=$truncationTmpValue"
2170 if {$completenessTmpValue > 0} {
2171 lappend attr "6=$completenessTmpValue"
2173 puts "new attr $attr"
2174 set queryInfoTmp [lreplace $queryInfoTmp $indexNo $indexNo $attr]
2175 destroy .index-setup
2178 proc index-setup {attr queryNo indexNo} {
2181 global relationTmpValue
2182 global structureTmpValue
2183 global truncationTmpValue
2184 global completenessTmpValue
2185 global positionTmpValue
2187 set relationTmpValue 0
2188 set truncationTmpValue 0
2189 set structureTmpValue 0
2190 set positionTmpValue 0
2191 set completenessTmpValue 0
2194 set len [llength $attr]
2195 for {set i 1} {$i < $len} {incr i} {
2196 set q [lindex $attr $i]
2197 set l [string first = $q]
2199 set t [string range $q 0 [expr $l - 1]]
2200 set v [string range $q [expr $l + 1] end]
2203 { set useTmpValue $v }
2205 { set relationTmpValue $v }
2207 { set positionTmpValue $v }
2209 { set structureTmpValue $v }
2211 { set truncationTmpValue $v }
2213 { set completenessTmpValue $v }
2217 if {[winfo exists $w]} {
2222 set n [lindex $attr 0]
2223 wm title $w "Index setup $n"
2227 frame $w.top.use -relief ridge -border 2
2228 frame $w.top.relation -relief ridge -border 2
2229 frame $w.top.position -relief ridge -border 2
2230 frame $w.top.structure -relief ridge -border 2
2231 frame $w.top.truncation -relief ridge -border 2
2232 frame $w.top.completeness -relief ridge -border 2
2238 pack $w.top.use -side left -pady 6 -padx 6 -fill y
2240 label $w.top.use.label -text "Use"
2241 listbox $w.top.use.list -geometry 26x10 \
2242 -yscrollcommand "$w.top.use.scroll set"
2243 scrollbar $w.top.use.scroll -orient vertical -border 1
2244 pack $w.top.use.label -side top -fill x \
2246 pack $w.top.use.list -side left -fill both -expand yes \
2248 pack $w.top.use.scroll -side right -fill y \
2250 $w.top.use.scroll config -command "$w.top.use.list yview"
2254 # Relation Attributes
2256 pack $w.top.relation -pady 6 -padx 6 -side top
2257 label $w.top.relation.label -text "Relation" -width 18
2259 pack $w.top.relation.label $w.top.relation.b -fill x
2261 # Position Attributes
2263 pack $w.top.position -pady 6 -padx 6 -side top
2264 label $w.top.position.label -text "Position" -width 18
2266 pack $w.top.position.label $w.top.position.b -fill x
2268 # Structure Attributes
2270 pack $w.top.structure -pady 6 -padx 6 -side top
2271 label $w.top.structure.label -text "Structure" -width 18
2273 pack $w.top.structure.label $w.top.structure.b -fill x
2275 # Truncation Attributes
2277 pack $w.top.truncation -pady 6 -padx 6 -side top
2278 label $w.top.truncation.label -text "Truncation" -width 18
2280 pack $w.top.truncation.label $w.top.truncation.b -fill x
2282 # Completeness Attributes
2284 pack $w.top.completeness -pady 6 -padx 6 -side top
2285 label $w.top.completeness.label -text "Completeness" -width 18
2287 pack $w.top.completeness.label $w.top.completeness.b -fill x
2290 bottom-buttons $w [list \
2291 {Ok} [list index-setup-action $attr $queryNo $indexNo] \
2292 {Cancel} [list destroy $w]] 0
2296 proc query-edit-index {queryNo} {
2300 set i [lindex [$w.top.index.list curselection] 0]
2304 set attr [lindex $queryInfoTmp $i]
2305 puts "Editing no $i $attr"
2306 index-setup $attr $queryNo $i
2309 proc query-delete-index {queryNo} {
2311 global queryButtonsTmp
2314 set i [lindex [$w.top.index.list curselection] 0]
2318 set queryInfoTmp [lreplace $queryInfoTmp $i $i]
2319 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2320 $w.top.index.list delete $i
2323 proc query-setup {queryNo} {
2329 global queryButtonsTmp
2331 global queryIndexTmp
2334 set queryName [lindex $queryTypes $queryNo]
2335 set queryInfoTmp [lindex $queryInfo $queryNo]
2336 set queryButtonsTmp [lindex $queryButtons $queryNo]
2341 wm title $w "Query setup $queryName"
2345 frame $w.top.lines -relief ridge -border 2
2347 pack $w.top.lines -side left -pady 6 -padx 6 -fill y
2351 index-lines $w.top.lines 0 $queryButtonsTmp $queryInfoTmp activate-e-index
2353 button $w.top.lines.add -text "Add" \
2354 -command [list query-add-line $queryNo]
2355 button $w.top.lines.del -text "Remove" \
2356 -command [list query-del-line $queryNo]
2358 pack $w.top.lines.del -fill x -side bottom
2359 pack $w.top.lines.add -fill x -pady 10 -side bottom
2363 frame $w.top.index -relief ridge -border 2
2364 pack $w.top.index -pady 6 -padx 6 -side right -fill y
2366 listbox $w.top.index.list -yscrollcommand [list $w.top.index.scroll set]
2367 scrollbar $w.top.index.scroll -orient vertical -border 1 \
2368 -command [list $w.top.index.list yview]
2369 bind $w.top.index.list <2> [list query-edit-index $queryNo]
2371 pack $w.top.index.list -side left -fill both -expand yes -padx 2 -pady 2
2372 pack $w.top.index.scroll -side right -fill y -padx 2 -pady 2
2374 $w.top.index.list select from 0
2375 $w.top.index.list select to 0
2377 foreach x $queryInfoTmp {
2378 $w.top.index.list insert end [lindex $x 0]
2381 bottom-buttons $w [list \
2382 {Ok} [list query-setup-action $queryNo] \
2383 {Add index} [list query-add-index $queryNo] \
2384 {Edit index} [list query-edit-index $queryNo] \
2385 {Delete index} [list query-delete-index $queryNo] \
2386 {Cancel} [list destroy $w]] 0
2389 proc index-clear {} {
2390 global queryButtonsFind
2393 foreach b $queryButtonsFind {
2394 .lines.$i.e delete 0 end
2399 proc index-query {} {
2400 global queryButtonsFind
2401 global queryInfoFind
2406 foreach b $queryButtonsFind {
2407 set term [string trim [.lines.$i.e get]]
2409 set attr [lrange [lindex $queryInfoFind [lindex $b 1]] 1 end]
2411 set len [string length $term]
2415 if {[string index $term $len] == "?"} {
2417 set term [string range $term 0 [expr $len - 1]]
2419 if {[string index $term 0] == "?"} {
2421 set term [string range $term 1 end]
2423 set term "\{${term}\}"
2424 if {$right && $left} {
2425 set term "@attr 5=3 ${term}"
2427 set term "@attr 5=1 ${term}"
2429 set term "@attr 5=2 ${term}"
2432 set term "@attr $a ${term}"
2435 set qs "@and ${qs} ${term}"
2446 proc index-focus-in {w i} {
2447 global curIndexEntry
2449 $w.$i configure -background red
2450 set curIndexEntry $i
2453 proc index-lines {w realOp buttonInfo queryInfo handle} {
2455 foreach b $buttonInfo {
2456 if {! [winfo exists $w.$i]} {
2457 frame $w.$i -background white -border 1
2459 listbuttonx $w.$i.l [lindex $b 1] $queryInfo $handle $i
2462 if {! [winfo exists $w.$i.e]} {
2463 entry $w.$i.e -width 32 -relief sunken -border 1
2464 bind $w.$i.e <FocusIn> [list index-focus-in $w $i]
2465 bind $w.$i.e <FocusOut> [list $w.$i configure \
2467 pack $w.$i.l -side left
2468 pack $w.$i.e -side left -fill x -expand yes
2469 pack $w.$i -side top -fill x -padx 2 -pady 2
2470 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2471 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2472 bind $w.$i.e <Return> search-request
2475 pack $w.$i.l -side left
2476 pack $w.$i -side top -fill x -padx 2 -pady 2
2481 while {[winfo exists $w.$j]} {
2492 bind $w.$j.e <Tab> "focus $w.$k.e"
2496 bind $w.$i.e <Tab> "focus $w.0.e"
2501 proc search-fields {w buttondefs} {
2503 foreach buttondef $buttondefs {
2504 frame $w.$i -background white
2506 listbutton $w.$i.l 0 $buttondef
2507 entry $w.$i.e -width 32 -relief sunken
2509 pack $w.$i.l -side left
2510 pack $w.$i.e -side left -fill x -expand yes
2512 pack $w.$i -side top -fill x -padx 2 -pady 2
2514 bind $w.$i.e <Left> [list left-cursor $w.$i.e]
2515 bind $w.$i.e <Right> [list right-cursor $w.$i.e]
2523 bind $w.$j.e <Tab> "focus $w.$k.e \n
2524 $w.$k configure -background red \n
2525 $w.$j configure -background white"
2528 bind $w.$i.e <Tab> "focus $w.0.e \n
2529 $w.0 configure -background red \n
2530 $w.$i configure -background white"
2532 $w.0 configure -background red
2535 if {[info exists windowGeometry(.)]} {
2536 set g $windowGeometry(.)
2544 frame .top -border 1 -relief raised
2545 frame .lines -border 1 -relief raised
2546 frame .mid -border 1 -relief raised
2547 frame .data -border 1 -relief raised
2548 frame .bot -border 1 -relief raised
2549 pack .top .lines .mid -side top -fill x
2550 pack .data -side top -fill both -expand yes
2553 menubutton .top.file -text "File" -menu .top.file.m
2555 .top.file.m add command -label "Save settings" -command {save-settings}
2556 .top.file.m add separator
2557 .top.file.m add command -label "Exit" -command {exit-action}
2559 menubutton .top.target -text "Target" -menu .top.target.m
2561 .top.target.m add cascade -label "Connect" -menu .top.target.m.clist
2562 .top.target.m add command -label "Disconnect" -command {close-target}
2563 .top.target.m add command -label "About" -command {about-target}
2564 .top.target.m add cascade -label "Setup" -menu .top.target.m.slist
2565 .top.target.m add command -label "Setup new" -command {define-target-dialog}
2566 .top.target.m add separator
2569 .top.target.m disable 1
2570 .top.target.m disable 2
2572 menu .top.target.m.clist
2573 menu .top.target.m.slist
2576 menubutton .top.service -text "Service" -menu .top.service.m
2578 .top.service.m add command -label "Database" -command {database-select}
2579 .top.service.m add cascade -label "Present" -menu .top.service.m.present
2580 menu .top.service.m.present
2581 .top.service.m.present add command -label "10 More" \
2582 -command [list present-more 10]
2583 .top.service.m.present add command -label "All" \
2584 -command [list present-more {}]
2585 .top.service.m add command -label "Search" -command {search-request}
2586 .top.service.m add command -label "Scan" -command {scan-request}
2588 .top.service configure -state disabled
2590 menubutton .top.rset -text "Set" -menu .top.rset.m
2592 .top.rset.m add command -label "Load" -command {load-set}
2593 .top.rset.m add separator
2595 menubutton .top.options -text "Options" -menu .top.options.m
2597 .top.options.m add cascade -label "Query" -menu .top.options.m.query
2598 .top.options.m add cascade -label "Format" -menu .top.options.m.formats
2599 .top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
2601 menu .top.options.m.query
2602 .top.options.m.query add cascade -label "Select" \
2603 -menu .top.options.m.query.clist
2604 .top.options.m.query add cascade -label "Edit" \
2605 -menu .top.options.m.query.slist
2606 .top.options.m.query add command -label "New" \
2607 -command {query-new}
2608 .top.options.m.query add cascade -label "Delete" \
2609 -menu .top.options.m.query.dlist
2611 menu .top.options.m.query.slist
2612 menu .top.options.m.query.clist
2613 menu .top.options.m.query.dlist
2616 menu .top.options.m.formats
2618 foreach f $displayFormats {
2619 .top.options.m.formats add radiobutton -label $f -value $i \
2620 -command [list set-display-format $i] -variable displayFormat
2624 menu .top.options.m.wrap
2625 .top.options.m.wrap add radiobutton -label "Character" \
2626 -value char -variable textWrap -command {set-wrap char}
2627 .top.options.m.wrap add radiobutton -label "Word" \
2628 -value word -variable textWrap -command {set-wrap word}
2629 .top.options.m.wrap add radiobutton -label "None" \
2630 -value none -variable textWrap -command {set-wrap none}
2632 menubutton .top.help -text "Help" -menu .top.help.m
2635 .top.help.m add command -label "Help on help" \
2636 -command {tkerror "Help on help not available. Sorry"}
2637 .top.help.m add command -label "About" -command {about-origin}
2639 pack .top.file .top.target .top.service .top.rset .top.options -side left
2640 pack .top.help -side right
2642 index-lines .lines 1 $queryButtonsFind [lindex $queryInfo 0] activate-index
2644 button .mid.search -width 7 -text {Search} -command search-request \
2646 button .mid.scan -width 7 -text {Scan} \
2647 -command scan-request -state disabled
2648 button .mid.present -width 7 -text {Present} -command [list present-more 10] \
2651 button .mid.clear -width 7 -text {Clear} -command index-clear
2652 pack .mid.search .mid.scan .mid.present .mid.clear -side left \
2653 -fill y -padx 5 -pady 3
2655 text .data.record -height 2 -width 20 -wrap none \
2656 -yscrollcommand [list .data.scroll set] -wrap $textWrap
2657 scrollbar .data.scroll -command [list .data.record yview]
2658 pack .data.scroll -side right -fill y
2659 pack .data.record -expand yes -fill both
2662 if {[tk colormodel .] == "color"} {
2663 .data.record tag configure marc-tag -foreground blue
2664 .data.record tag configure marc-id -foreground red
2666 .data.record tag configure marc-tag -foreground black
2667 .data.record tag configure marc-id -foreground black
2669 .data.record tag configure marc-data -foreground black
2671 button .bot.logo -bitmap @book1 -command cancel-operation
2673 pack .bot.a -side left -fill x
2674 pack .bot.logo -side right -padx 2 -pady 2
2676 message .bot.a.target -text "" -aspect 1000 -border 1
2678 label .bot.a.status -text "Not connected" -width 15 -relief \
2679 sunken -anchor w -border 1
2680 label .bot.a.set -text "" -width 5 -relief \
2681 sunken -anchor w -border 1
2682 label .bot.a.message -text "" -width 15 -relief \
2683 sunken -anchor w -border 1
2685 pack .bot.a.target -side top -anchor nw -padx 2 -pady 2
2686 pack .bot.a.status .bot.a.set .bot.a.message \
2687 -side left -padx 2 -pady 2