Cover V04, I06
Article
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5

nov95.tar


Listing 3: The forms shell script

# Listing 3
# forms - creates and processes forms, menus and online
#         help
#
case $# in
0|1) echo "Usage: forms formname commandfile" 1>&2;
echo " " 1>&2;
echo "Where:" 1>&2;
echo "       formname is the form \c" 1>&2;
echo "label in the command file" 1>&2;
echo "       commandfile is the file \c" 1>&2;
echo "containing forms commands" 1>&2; exit 2
;;
2)   if test ! -f $2
then
echo "Usage: forms formname \c" 1>&2;
echo "commandfile" 1>&2;
echo "Error: commandfile $2 not \c" 1>&2;
echo "found" 1>&2; exit 2
fi
;;
*)   echo "Usage: forms formname commandfile" 1>&2;
echo " " 1>&2;
echo "Where:" 1>&2;
echo "       formname is the form \c" 1>&2;
echo "label in the command file" 1>&2;
echo "       commandfile is the file \c" 1>&2;
echo "containing forms commands" 1>&2; exit 2
;;
esac
FORM=$1
CFILE=$2
CMDS=$FORM$$
while grep -e "<$FORM>" -e "<$FORM p>" $CFILE 1>&2
>/dev/null
do
grep "<$FORM>" $CFILE|sed s/\<$FORM\>//
grep "<$FORM p>" $CFILE|sed s/\<"$FORM p"\>// >$CMDS
chmod 755 $CMDS
$CMDS
rm $CMDS
FORM=`cat formkey`
CMDS=$FORM$$
done
# End of File