%% scmac.tex
%% TeX macros for typesetting scripts version 2.00
%% Copyright (C) 1989 by Na Choon Piaw
%% This file may be freely used, distributed, and modified provided
%% credit is given to the original author.  You can even try to sell it,
%% assuming someone's willing to pay for this, of course.

%% This is a major rewrite --- hence, no change update is given.
%% For more information see the user's documentation.

%% tell user what version

\immediate\write16{Loading scmac version 2.00 Beta release ...}

%% fonts --- Use Computer Modern.  Substitute these with local
%%           equivalents if no Computer Modern.
\font\bigtenrm=cmr10 scaled\magstep2	%% big font for title
\font\rm=cmr10				%% standard roman text
\font\bf=cmbx10				%% for bold
\font\sl=cmsl10				%% slanted text
\font\it=cmti10				%% italics

%% variable declarations
\newcount\fnotecnt
\newcount\FootNoteStyle
\newcount\Style
\newwrite\auxfile
\fnotecnt=1
\FootNoteStyle=1			%% "true" footnotes
\Style=1

%% preamble handling
\def\Title{}
\def\transl{}
\def\oth{}
\def\cpmessage{}
\def\heading#1{\global\headline={\bf #1 \hfil Page \folio}}
\def\translator#1{\edef\transl{\noindent\it Translation by #1.\hfil}}
\def\others#1{\edef\oth{\noindent\it #1.\hfil}}
\footline={\hfil}

%% open auxilary file.
\immediate\openout\auxfile=\jobname.aux

%% Environments
\def\beginscript{
	\Title
	\cpmessage
	\transl
	\oth
	%% Open output file for footnotes
	%% Can your wordprocessor do this?
}

\def\endscript{
\immediate\closeout\auxfile
\ifnum\FootNoteStyle=1
	\relax
\else
	%% read in from aux file.
	\bigskip
	\filbreak
	\line{\bf Footnotes\hfil}
	\openin 1 = \jobname.aux
	\readfootnotes
\fi
}

%% songs
\def\beginsong{\bigskip\begingroup\obeylines\narrower}
\def\endsong{\par\endgroup\bigskip}

\def\readfootnotes{
%% recursive TeX macro!  Can WordPerfect do this?
\def\temp{}
\ifeof 1
	\relax
\else
	\read 1 to \temp
	\ifeof 1
		\relax
	\else
		\item{[\temp]}
		\read 1 to \temp
		\temp
		\readfootnotes
	\fi
\fi
}

%% describe and desc are unchanged.
\def\describe#1{\sl #1 \medskip\goodbreak}
\def\desc#1{\it (#1\/)\rm}

%% footnoting
\def\fnote#1{\ifnum\FootNoteStyle=1				
%% footnotes at bottom of page
 	\footnote{$^{\the\fnotecnt}$}{\rm #1}
\else 
%% new-style typeinto aux file  for readback
%% remember to change the \hskip value for different fonts!
	$^{\the\fnotecnt}$ \hskip -0.15in
	\immediate\write\auxfile{\the\fnotecnt}
	\immediate\write\auxfile{#1}
\fi
\global\advance\fnotecnt by 1
}

%% unavoidable processing
\ifnum\Style=1
        %% old style: version 1.xx
	\gdef\say#1#2{
		\centerline{\bf #1}
		{
			\parindent=1in
			\rm\narrower\raggedright\noindent
			#2
			\par
		}
		\bigskip\goodbreak
	}
\else
	%% version 2.xx
	\gdef\say#1:#2\par{
		\centerline{\bf #1}
		{
			\parindent=1in
			\rm\narrower\raggedright\noindent
			#2
			\par
		}
		\bigskip\goodbreak
	}
\fi