#!/vol/pub/tcl-7.3/bin/tclsh
#
# This is a very simple Tcl script that handles clicks on the
# rendering of California.
#
proc html_run {body} {
if {[catch {uplevel $body}] == 1} {
global errorInfo
html "
Ooops!
An error occurred in a tcl script:"
html ""
html "$errorInfo"
html ""
html ""
}
}
puts "Content-type: text/html"
puts ""
html_run {
# find the proper row/col
set rows 4
set cols 4
set w 450
set h 465
set tmp [split [lindex $argv 0] ","]
set y [lindex $tmp 0]
set x [lindex $tmp 1]
set row [expr int(double($x)/$w*$cols)]
set col [expr int(double($y)/$h*$rows)]
set prefix tiles/[format "ca-%02d-%02d" $row $col]
puts {
Section of California
}
puts "[format "ca-%02d-%02d" $row $col].jpg
"
puts "
"
if [file exists $prefix.html] {
set fp [open $prefix.html r]
puts [read $fp]
close $fp
} else {
puts "This section ($prefix.jpg) has no annotations."
}
puts {
Sam Shen <slshen@lbl.gov>
}
}