# Sebastian Hammer, Adam Dickmeiss
#
# $Log: client.tcl,v $
-# Revision 1.50 1995-06-21 11:04:48 adam
+# Revision 1.57 1995-06-29 09:20:30 adam
+# Target entries in cascade menus are sorted.
+#
+# Revision 1.56 1995/06/27 19:03:48 adam
+# Bug fix in do_present in ir-tcl.c: p->set_child member weren't set.
+# nextResultSetPosition used instead of setOffset.
+#
+# Revision 1.55 1995/06/27 17:10:37 adam
+# Bug fix: install procedure didn't work on some systems.
+# Error turned up when clientrc.tcl was't present.
+#
+# Revision 1.54 1995/06/27 14:41:03 adam
+# Bug fix in search-response. Didn't always observe non-surrogate diagnostics.
+#
+# Revision 1.53 1995/06/26 12:40:09 adam
+# Client defines its own tkerror.
+# User may specify 'no preferredRecordSyntax'.
+#
+# Revision 1.52 1995/06/22 13:14:59 adam
+# Feature: SUTRS. Setting getSutrs implemented.
+# Work on display formats.
+# Preferred record syntax can be set by the user.
+#
+# Revision 1.51 1995/06/21 11:11:00 adam
+# Bug fix: libdir undefined in about-origin.
+#
+# Revision 1.50 1995/06/21 11:04:48 adam
# Uses GNU autoconf 2.3.
# Install procedure implemented.
# boook bitmaps moved to sub directory bitmaps.
#
set libdir LIBDIR
-if {[file readable clientrc.tcl]} {
+if {[file readable bitmaps/book2]} {
set libdir .
}
+if {! [file readable ${libdir}/bitmaps/book2]} {
+ puts "Cannot locate system files in ${libdir}. You must either run this"
+ puts "program from the source directory root of ir-tcl or you must assure"
+ puts "that it is installed - normally in /usr/local/lib/irtcl"
+ exit 1
+}
+
set hotTargets {}
set hotInfo {}
set busy 0
-set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} Z39}
+set profile(Default) {{} {} {210} {} 16384 8192 tcpip {} 1 {} {} Z39 1}
set hostid Default
set settingsChanged 0
set setNo 0
-set lastSetNo 0
+set setNoLast 0
set cancelFlag 0
set scanEnable 0
set fullMarcSeq 0
set displayFormat 1
set popupMarcdf 0
set textWrap word
+set recordSyntax None
set delayRequest {}
set queryTypes {Simple}
set setOffset 0
set setMax 0
+proc tkerror err {
+ set w .tkerrorw
+
+ if {[winfo exists $w]} {
+ destroy $w
+ }
+ toplevel $w
+ wm title $w "Error"
+
+ place-force $w .
+ top-down-window $w
+
+ label $w.top.b -bitmap error
+ message $w.top.t -aspect 300 -text "Error: $err" \
+ -font -Adobe-Helvetica-Bold-R-Normal-*-240-*
+ pack $w.top.b $w.top.t -side left -padx 10 -pady 10
+
+ bottom-buttons $w [list {Close} [list destroy $w]] 1
+}
+
proc read-formats {} {
global displayFormats
global libdir
set formats [glob -nocomplain ${libdir}/formats/*.tcl]
foreach f $formats {
if {[file readable $f]} {
- source $f
- set l [expr [string length $f] - 5]
- lappend displayFormats [string range $f 8 $l]
+ source $f
+ set l [string length $f]
+ set f [string range $f [string length "${libdir}/formats/"] \
+ [expr $l - 5]]
+ lappend displayFormats $f
}
}
}
.bot.a.status configure -text "Reformatting"
}
update idletasks
- add-title-lines 0 10000 1
- if {!$busy} {
- .bot.a.status configure -text "Ready"
- }
+ add-title-lines -1 10000 1
}
proc initBindings {} {
bind $w <Destroy> [list destroyGW $w]
}
-if {[file readable "${libdir}/clientrc.tcl"]} {
- source "${libdir}/clientrc.tcl"
+if {[file readable "clientrc.tcl"]} {
+ source "clientrc.tcl"
+} else {
+ if {[file readable "${libdir}/clientrc.tcl"]} {
+ source "${libdir}/clientrc.tcl"
+ }
}
if {[file readable "~/.clientrc.tcl"]} {
}
if {$setNo == 0} {
.top.service.m disable 1
- } elseif {$setOffset > 0 && $setOffset <= [z39.$setNo resultCount]} {
+ } elseif {[z39.$setNo nextResultSetPosition] > 0 &&
+ [z39.$setNo nextResultSetPosition] <= [z39.$setNo resultCount]} {
.top.service.m enable 1
.mid.present configure -state normal
} else {
.top.service.m disable 1
+ .mid.present configure -state disabled
}
if {[winfo exists .scan-window]} {
.scan-window.bot.2 configure -state normal
toplevel $w
wm title $w "About target"
+ place-force $w .
top-down-window $w
frame $w.top.a -relief ridge -border 2
proc about-origin {} {
set w .about-origin-w
+ global libdir
if {[winfo exists $w]} {
destroy $w
set recordType [z39.$sno recordType $no]
wm title $w "$recordType record #$no"
- set ffunc [lindex $displayFormats $df]
- set ffunc "display-$ffunc"
-
- $ffunc $sno $no $w.top.record 0
-
if {$new} {
bind $w.top.record <Return> {destroy .full-marc}
incr i
}
}
+ set ffunc [lindex $displayFormats $df]
+ set ffunc "display-$ffunc"
+
+ $ffunc $sno $no $w.top.record 0
}
proc update-target-hotlist {target base} {
show-status Ready 0 {}
return
}
-# z39 options search present scan namedResultSets triggerResourceCtrl
set hostid $target
.top.target.m disable 0
.top.target.m enable 1
global hostid
global cancelFlag
global setNo
+ global setNoLast
set cancelFlag 0
set setNo 0
+ set setNoLast 0
.bot.a.set configure -text ""
set hostid Default
z39 disconnect
show-message {}
.top.target.m disable 1
.top.target.m disable 2
+ .top.rset.m delete 1 last
+ .top.rset.m add separator
.top.target.m enable 0
}
proc load-set-action {} {
- global setNo
+ global setNoLast
- incr setNo
- ir-set z39.$setNo z39
+ incr setNoLast
+ ir-set z39.$setNoLast z39
set fname [.load-set.top.filename.entry get]
destroy .load-set
update
z39.$setNo loadFile $fname
- set no [z39.$setNo numberOfRecordsReturned]
- add-title-lines $setNo $no 1
+ set no [z39.$setNoLast numberOfRecordsReturned]
+ add-title-lines $setNoLast $no 1
}
- set l [format "%-4d %7d" $setNo $no]
+ set l [format "%-4d %7d" $setNoLast $no]
.top.rset.m add command -label $l \
- -command [list add-title-lines $setNo 10000 1]
+ -command [list add-title-lines $setNoLast 10000 1]
show-status {Ready} 0 {}
}
}
proc init-request {} {
- global setNo
global cancelFlag
if {$cancelFlag} {
proc search-request {bflag} {
global setNo
+ global setNoLast
global profile
global hostid
global busy
global cancelFlag
global delayRequest
+ global recordSyntax
set target $hostid
if {$query==""} {
return
}
- incr setNo
+ incr setNoLast
+ set setNo $setNoLast
ir-set z39.$setNo z39
if {[lindex $profile($target) 10] == 1} {
if {[lindex $profile($target) 9] == 1} {
z39.$setNo queryType ccl
}
+ dputs Setting
+ dputs $recordSyntax
+ if {$recordSyntax == "None" } {
+ z39.$setNo preferredRecordSyntax {}
+ } else {
+ z39.$setNo preferredRecordSyntax $recordSyntax
+ }
z39 callback {search-response}
z39.$setNo search $query
show-status {Searching} 1 0
}
return
}
+ set setOffset 0
set delayRequest {}
init-title-lines
set setMax [z39.$setNo resultCount]
+ show-status {Ready} 0 1
+ set status [z39.$setNo responseStatus]
+ if {[lindex $status 0] == "NSD"} {
+ z39.$setNo nextResultSetPosition 0
+ set code [lindex $status 1]
+ set msg [lindex $status 2]
+ set addinfo [lindex $status 3]
+ tkerror "NSD$code: $msg: $addinfo"
+ return
+ }
show-message "${setMax} hits"
+ if {$setMax == 0} {
+ return
+ }
+ set setOffset 1
+ show-status {Ready} 0 1
set l [format "%-4d %7d" $setNo $setMax]
.top.rset.m add command -label $l \
-command [list add-title-lines $setNo 10000 1]
- if {$setMax <= 0} {
- show-status {Ready} 0 1
- set status [z39.$setNo responseStatus]
- if {[lindex $status 0] == "NSD"} {
- set code [lindex $status 1]
- set msg [lindex $status 2]
- set addinfo [lindex $status 3]
- tkerror "NSD$code: $msg: $addinfo"
- }
- return
- }
if {$setMax > 20} {
set setMax 20
}
- set setOffset 1
- show-status {Ready} 0 1
z39 callback {present-response}
z39.$setNo present $setOffset 1
show-status {Retrieving} 1 0
dputs "setNo=$setNo"
return
}
+ set setOffset [z39.$setNo nextResultSetPosition]
+ dputs "setOffest=${setOffset}"
+ dputs "setNo=${setNo}"
set max [z39.$setNo resultCount]
- if {$max <= $setOffset} {
+ if {$max < $setOffset} {
dputs "max=$max"
dputs "setOffset=$setOffset"
+ show-status Ready 0 1
return
}
if {$number == ""} {
proc add-title-lines {setno no offset} {
global displayFormats
global displayFormat
- global lastSetNo
+ global setNo
+ global busy
- if {$setno == 0} {
- set setno $lastSetNo
+ if {$setno != -1} {
+ set setNo $setno
} else {
- set lastSetNo $setno
+ set setno $setNo
}
if {$offset == 1} {
.bot.a.set configure -text $setno
.data.record delete 0.0 end
}
set ffunc [lindex $displayFormats $displayFormat]
+ dputs "ffunc=$ffunc"
set ffunc "display-$ffunc"
for {set i 0} {$i < $no} {incr i} {
set o [expr $i + $offset]
[list popup-marc $setno $o 0 0]
update idletasks
}
+ if {!$busy} {
+ show-status Ready 0 1
+ }
}
proc present-response {} {
destroy $sub
}
.top.target.m.clist delete 0 last
- foreach n [array names profile] {
+ foreach n [lsort [array names profile]] {
if {$n != "Default"} {
set nl [lindex $profile($n) 12]
if {[llength [lindex $profile($n) 7]] > 1} {
}
}
.top.target.m.slist delete 0 last
- foreach n [array names profile] {
+ foreach n [lsort [array names profile]] {
if {$n != "Default"} {
.top.target.m.slist add command -label $n \
-command [list protocol-setup $n]
label $w.top.warning -bitmap warning
message $w.top.quest -text "Are you sure you want to delete the \
-query type $n ?" -aspect 200
+query type $n ?" -aspect 300
pack $w.top.warning $w.top.quest -side left -expand yes -padx 10 -pady 5
bottom-buttons $w [list {Ok} [list query-delete-action $queryNo] \
{Cancel} [list destroy $w]] 1
global textWrap
global displayFormat
global popupMarcdf
+ global recordSyntax
set windowGeometry(.) [wm geometry .]
puts $f "set textWrap $textWrap"
puts $f "set displayFormat $displayFormat"
puts $f "set popupMarcdf $popupMarcdf"
+ puts $f "set recordSyntax $recordSyntax"
foreach n [array names windowGeometry] {
puts -nonewline $f "set \{windowGeometry($n)\} \{"
puts -nonewline $f $windowGeometry($n)
global queryButtons
global queryInfo
- if {![file writeable "${libdir}/clientrc.tcl"]} {
- return
+ if {![file writable "${libdir}/clientrc.tcl"]} {
+ set a [alert "Cannot open ${libdir}/clientrc.tcl for writing. Do you \
+ wish to save clientrc.tcl in the current directory instead?"]
+ if {! $a} {
+ return
+ }
+ set f [open "clientrc.tcl" w]
+ } else {
+ set f [open "${libdir}/clientrc.tcl" w]
}
- set f [open "${libdir}/clientrc.tcl" w]
puts $f "# Setup file"
foreach n [array names profile] {
top-down-window $w
label $w.top.warning -bitmap warning
- message $w.top.message -text $ask -aspect 200 \
+ message $w.top.message -text $ask -aspect 300 \
-font -Adobe-Times-Medium-R-Normal-*-180-*
pack $w.top.warning $w.top.message -side left -pady 5 -padx 10 -expand yes
.top.options.m add cascade -label "Query" -menu .top.options.m.query
.top.options.m add cascade -label "Format" -menu .top.options.m.formats
.top.options.m add cascade -label "Wrap" -menu .top.options.m.wrap
+.top.options.m add cascade -label "Syntax" -menu .top.options.m.syntax
menu .top.options.m.query
.top.options.m.query add cascade -label "Select" \
.top.options.m.wrap add radiobutton -label "None" \
-value none -variable textWrap -command {set-wrap none}
+menu .top.options.m.syntax
+.top.options.m.syntax add radiobutton -label "None" \
+ -value None -variable recordSyntax
+.top.options.m.syntax add separator
+.top.options.m.syntax add radiobutton -label "USMARC" \
+ -value USMARC -variable recordSyntax
+.top.options.m.syntax add radiobutton -label "UNIMARC" \
+ -value UNIMARC -variable recordSyntax
+.top.options.m.syntax add radiobutton -label "UKMARC" \
+ -value UKMARC -variable recordSyntax
+.top.options.m.syntax add radiobutton -label "DANMARC" \
+ -value DANMARC -variable recordSyntax
+.top.options.m.syntax add radiobutton -label "FINMARC" \
+ -value FINMARC -variable recordSyntax
+.top.options.m.syntax add radiobutton -label "NORMARC" \
+ -value NORMARC -variable recordSyntax
+.top.options.m.syntax add radiobutton -label "PICAMARC" \
+ -value PICAMARC -variable recordSyntax
+.top.options.m.syntax add separator
+.top.options.m.syntax add radiobutton -label "SUTRS" \
+ -value SUTRS -variable recordSyntax
+
menubutton .top.help -text "Help" -menu .top.help.m
menu .top.help.m