#
-# $Id: z39util.tcl,v 1.8 1995/11/13 15:41:46 adam Exp $
+# $Id: z39util.tcl,v 1.9 1995/11/13 18:17:48 adam Exp $
#
proc saveState {} {
uplevel #0 {
set code [lindex $status 1]
set msg [lindex $status 2]
set addinfo [lindex $status 3]
- html "<h2>Error NSD$code: $msg: $addinfo </h2><br>\n"
+ displayError "Diagnostic message" \
+ "$msg: $addinfo<br>\n(error code $code)"
set sessionWait -2
} else {
set sessionWait 1
set sessionWait 0
if {[catch [list $zz connect $host]]} {
- html "Cannot connect to target ${host} <br>\n"
+ displayError "Cannot connect to target" $host
return 0
} elseif {$sessionWait == 0} {
zwait sessionWait
if {$sessionWait != 1} {
- html "Cannot connect to target ${host} <br>\n"
+ displayError "Cannot connect to target" $host
return 0
}
}
$zz idAuthentication $idAuth
set sessionWait 0
- if {[catch [list $zz init]]} {
- html "Cannot initialize with target ${host} <br>\n"
+ if {[catch {$zz init}]} {
+ displayError "Cannot initialize target" $host
return 0
}
if {[catch {zwait sessionWait 60}]} {
- html "Cannot initialize with target ${host} <br>\n"
+ displayError "Cannot initialize target" $host
$zz disconnect
return 0
}
if {$sessionWait != "1"} {
- html "Cannot initialize with target ${host} <br>\n"
+ displayError "Cannot initialize target" $host
$zz disconnect
return 0
}
if {![$zz initResult]} {
set u [$zz userInformationField]
$zz disconnect
- html "Connection rejected by target: $u <br>\n"
+ displayError "Cannot initialize target $host" $u
return 0
}
}
$zz.$setNo recordElements $elements
eval $zz.$setNo databaseNames $database
-
$zz.$setNo preferredRecordSyntax USMARC
$zz callback search-response $setNo
$zz.$setNo search $query
if {[catch {zwait sessionWait 600}]} {
+ displayError "Timeout in search" {}
html "</body></html>\n"
$zz disconnect
return 0
}
if {$sessionWait != 1} {
+ displayError "Search fail" "Connection closed"
html "</body></html>\n"
$zz disconnect
return 0
set code [lindex $status 1]
set msg [lindex $status 2]
set addinfo [lindex $status 3]
- html "<h2>Error NSD$code: $msg: $addinfo </h2><br>\n"
+ displayError "Diagnostic message" \
+ "$msg: $addinfo\n<br>(error code $code)"
return 0
}
set hist($setNo,hits) [$zz.$setNo resultCount]
$zz disconnect
break
}
+ if {$sessionWait == "0"} {
+ $zz disconnect
+ }
if {$sessionWait != "1"} {
break
}
for {set setNo 1} {$setNo < $nextSetNo} {incr setNo} {
html {<dt> <a href="http:} $env(SCRIPT_NAME)
html / $sessionId {/search.egw/} $setNo + 1
- html + [expr $hist($setNo,maxPresent) - 1]
+ html + $hist($setNo,maxPresent)
html {"> } [lindex $targets($hist($setNo,host)) 0]
if {[llength $hist($setNo,database)] > 1} {
html ": "
}
html "</dl>\n"
}
+
+proc displayError {msga msgb} {
+ html "<p><center>\n"
+ html {<img src="/gif/noway.gif">}
+ html "<h2>" $msga "</h2>\n"
+ if {$msgb != ""} {
+ html "<h3>" $msgb "</h3>\n"
+ }
+ html "</center><p>\n"
+}