-# $Id: iterate.tcl,v 1.4 1995-08-04 11:32:40 adam Exp $
+# $Id: iterate.tcl,v 1.5 1996-08-21 11:24:01 adam Exp $
#
# Small test script which searches for science ...
proc fail-back {} {
z failback {fail-back}
z databaseNames dummy
z callback {connect-response}
-z connect localhost:210
-
+z connect localhost:9999
+vwait forever
-# $Id: shell.tcl,v 1.2 1995-08-28 12:21:22 adam Exp $
+# $Id: shell.tcl,v 1.3 1996-08-21 11:24:03 adam Exp $
#
source display.tcl
ir z
+set pref(base) Default
+set pref(format) usmarc
proc help {} {
puts "Commands:"
- puts " target <host> <database>"
+ puts " target <host>"
+ puts " base <base>"
+ puts " format <format>"
puts " find <query>"
puts " show <offset> <number>"
puts ""
}
-proc target {name database} {
+proc fail-response {} {
+ global ok
+ set ok -1
+}
+proc target {name} {
+ global ok pref
+
+ set ok 0
z disconnect
- z failback {puts "Connection failed"}
+ z failback {fail-response}
z callback {connect-response}
- z databaseNames $database
- z connect $name
+ if [catch "z connect $name"] {
+ fail-response
+ } else {
+ vwait ok
+ }
return {}
}
+proc base {base} {
+ global pref
+ set pref(base) $base
+}
+
+proc format {format} {
+ global pref
+ set pref(format) $format
+}
+
proc connect-response {} {
z callback {init-response}
z init
}
proc init-response {} {
- puts "Connect and initialized."
+ global ok pref
+
+ set ok 1
+ puts "Connected and initialized."
+ ir-set z.1 z
}
proc find-response {z} {
}
proc common-response {z from} {
- set status [lindex [$z responseStatus] 0]
- switch $status {
+ global ok pref
+
+ set ok 1
+ set status [$z responseStatus]
+ switch [lindex $status 0] {
NSD {
puts -nonewline "NSD"
- puts -nonewline [lindex [$z responseStatus] 1]
+ puts -nonewline [lindex $status 1]
puts -nonewline " "
- puts -nonewline [lindex [$z responseStatus] 2]
+ puts -nonewline [lindex $status 2]
puts -nonewline ": "
- puts -nonewline [lindex [$z responseStatus] 3]
+ puts -nonewline [lindex $status 3]
puts ""
}
DBOSD {
}
proc show {from number} {
+ global ok pref
+
+ set ok 0
z callback "common-response z.1 $from"
z.1 present $from $number
+ vwait ok
+ return {}
}
proc find {query} {
- ir-set z.1 z
- z failback {puts "Connection closed"}
+ global ok pref
+
+ set ok 0
+ z.1 databaseNames $pref(base)
+ z.1 preferredRecordSyntax $pref(format)
z callback {find-response z.1}
z.1 search $query
+ vwait ok
+ return {}
}