\input eplain

\newcount\subsectionno

\def\tocsubsectionentry#1#2#3{\leftline{Subsection #2.~#1\dotfill#3}}
\let\tocentry = \tocsubsectionentry

\readtocfile

\subsectionno = 13

\writetocentry{chapter}{beginning}
\writetocentry{section}{subbeginning $\sin$}

\advance\subsectionno by 1
\writenumberedtocentry{subsection}{Subsection $\cos$ \#14}
  {\the\subsectionno}

\advance\subsectionno by 1
\writenumberedtocentry{subsection}{Subsection \#15}{\the\subsectionno}

% This doesn't expand \the\subsectionno -- only the first token gets
% expanded. Its output line starts with \tocentry.
\writenumberedtocentry{}{A toc entry}{1{\the\subsectionno}}

%\loggingall

\bye
