while [ "$command" != 'x' ] 
do
tput clear
echo
echo
echo
echo
echo '*********************** Sample Application menu *********************'
echo
echo '                      Student Billing Sample'
echo
echo
echo ' (e) Enter student information'  
echo ' (d) eDit data'
echo ' (p) Print student mailing list'
echo ' (b) Back up the data file ' 
echo ' (x) eXit menu system '
echo
echo '*********************************************************************'
read command 
if [ "$command" = "e" ] || [ "$command" = "E" ]
then
	sci -h -l -s -d 
elif [ "$command" = "p" ] || [ "$command" = "p" ]
then
	tput clear
	./sortd 9 scidata.out | awk -F"\t" -f maillist.awk 
	echo 'Press return to continue'
	read dummy
elif [ "$command" = "d" ] || [ "$command" = "D" ]
then
	if ln template.sci dud
	then
		if sci -h -t "whch" -o "whch.out"
		then
			read field < whch.out
			wc -l scidata.out | cut -d ' ' -f 7 > whch.out
			read lines < whch.out
			if x=`expr "$lines" ">=" "$field"`
			then
				grep -v ^'#' template.sci | grep -v "@def" > edit
				awk -F"\t" -f edit.awk keynum=12 key=$field scidata.out >> edit
				count=`expr $field - 1`
				echo $count > edit.num
				if sci -h -s -d -t edit -o edit.out		
				then
					awk -F"\t" -f allbut.awk keynum=12 key=$field scidata.out > temp.out
					./merge 12 edit.out temp.out > tempy.out
					mv scidata.out dud.out
					mv tempy.out scidata.out
				fi
			fi
		fi
		rm -f whch.out edit edit.out edit.num temp.out dud.out dud 
	else
		tput clear
		echo 
		echo "Sorry, someone else is editing the file!"
		echo "Press return to continue"
		read dummy
	fi
elif [ "$command" = "b" ] || [ "$command" = "B" ]
then
	mcopy scidata.out a:
elif [ "$command" = "x" ] || [ "$command" = "X" ]
then
	command=x
fi
done
tput clear



