#!/opt/tcl/bin/sytcl
#/usr/local/tcl74/bin/dbtcl
#
set tclroot /opt/share/tcl
# set tclroot /usr/local/tcl74
#
loadlibindex $tclroot/lib/ucodb/ucodb.tlib
#
set dbpipe1 [sybOpen keck guest rsvp UCO-ASTRO]
echo "got dbpipe $dbpipe1"
#
global sybmsg
#
set memtbl keck.dbo.Memes
set mebtbl keck.dbo.Mbundles
#
set uniq [getclock]
set outfile $argv
set ofp [open $outfile w]
#
set boiler1 "<HTML> \
<HEAD> \n\
<TITLE>Meme Bundles</title> \n\
</HEAD> \n\
<BODY> \n\
<H1>Meme Bundles (Headers, Tables, Tuples)</h1> \n\
<h2>provided by The Scientific Programming Group</H2> \n\
<H3>UCO / Lick Observatory</H3> \n"
#
set boiler2 "<p> \n\
<hr> \n\
<p> \n\
<ADDRESS> \n\
A Public Service of UCO/Lick Observatory <br> \n\
Courtesy of the Scientific Programming Group <br> \n\
Using Sybase Server, Tcl, HTML<br> \n\
<a href=\"mailto:webmaster@ucolick.org\">webmaster@ucolick.org</a> \n\
</address> \n\
</BODY> \n\
</HTML>"
#
puts $ofp "$boiler1"
#
set sqlcmd "select mid,name,syty,context,semantics from $memtbl where mid in (select distinct tmid from $mebtbl) order by syty,context" 
set sqt $memtbl
doSQL 1
#
set cols [sybCols 1]
set lasts "XXX"
set first 1
while {1} {
	set line [sybNext 1]
	if {$line == ""} {break}
	eval lassign \$line $cols
	if {$lasts != $syty} {
		if {!$first} {
		puts $ofp "</dl>"
		}
		puts $ofp "<hr><h2>${syty}s</h2><dl>"
		set first 0
	}
	puts $ofp "<dt><b>$name</b> ($context)"
	puts $ofp "<dd><i>$semantics</i>"
	set lasts $syty
}
puts $ofp "</dl>"
#
puts $ofp "$boiler2"
#
close $ofp
#
