#!/bin/sh

i=`cat .build/snum`
appname=applet$i

prevname=applet`echo $i - 1 | bc`
rm -f $prevname.java $prevname.class

cat wtmain.java | sed "s/wtmain/$appname/" >$appname.java
javac $appname.java
if [ "$?" != "0" ]; then
    exit 0;
fi

cat .build/ht.head >foo.html
echo "<applet code=\"$appname\" width=\"320\" height=\"240\"></applet>" >>foo.html
cat .build/ht.tail >>foo.html

echo `echo $i + 1 | bc` >.build/snum