# Print the COHERENT tutorials, one by one.
# by fwb, 8/91
#
# copyright (c) 1991-1993 by Mark Williams Company, Northbrook Ill.

INPUT=/v/doc/coherent
OUTPUT=/tmp/doc
>pgn.r

# text for two, and only two, command-line options
if [ $# -ne 1 ]; then
	echo "Usage: Run.text tutorial"
	exit
fi

# extract the section number and page number from the previous section
case $1 in
	intro)		echo ".pn 1" >pgn.r			;;
	using)		tail -1 $OUTPUT/intro.x >pgn.r		;;
	sh)		tail -1 $OUTPUT/using.x >pgn.r		;;
	emacs)		tail -1 $OUTPUT/sh.x >pgn.r		;;
	ed)		tail -1 $OUTPUT/emacs.x >pgn.r		;;
	sed)		tail -1 $OUTPUT/ed.x >pgn.r		;;
	c_language)	tail -1 $OUTPUT/sed.x >pgn.r		;;
	awk)		tail -1 $OUTPUT/c_language.x >pgn.r	;;
	lex)		tail -1 $OUTPUT/awk.x >pgn.r		;;
	yacc)		tail -1 $OUTPUT/lex.x >pgn.r		;;
	bc)		tail -1 $OUTPUT/yacc.x >pgn.r		;;
	m4)		tail -1 $OUTPUT/bc.x >pgn.r		;;
	make)		tail -1 $OUTPUT/m4.x >pgn.r		;;
	nroff)		tail -1 $OUTPUT/make.x >pgn.r		;;
	uucp)		tail -1 $OUTPUT/nroff.x >pgn.r		;;
	lexicon)	tail -1 $OUTPUT/uucp.x >pgn.r		;;
	*)		echo "Unrecognized option $1"
			exit					;;
esac

# and troff the appropriate file
troff -p -Z -rX0 -mcohtext fonts.r pgn.r top.r $INPUT/text/$1.r \
	2>$OUTPUT/$1.x > $OUTPUT/$1.p
