\newread\lst@R
\newcount\cnt@R
\newcount\cntr@R
\newcount\cntpb@R
\newcount\RECnumber
\newtoks\task@R

\def\dorecord@R{\ifnum\cntr@R>0
  \global\advance\cntr@R-1
  \global\advance\cntpb@R 1
  \global\advance\RECnumber 1 \message{\the\RECnumber }%
  \gdef\nxxt@R{\the\task@R \dorecord@R}%
  \ifnum\cntpb@R>\pba@R \global\cntpb@R=1 \message{pb }\pbc@R \fi
  \read\lst@R to \rec@R
  \expandafter\ifx\rec@R\endinput \noalign@R{\gdef\nxxt@R{}}\else
  \global\cnt@R=0 \expandafter\assign@R\rec@R \fi
  \else\noalign@R{\gdef\nxxt@R{}}\fi\nxxt@R}

\let\pbc@R\clearpage

\long\def\assign@R#1 {\advance\cnt@R by 1
\expandafter\expandafter\expandafter\gdef\csname REC@\the\cnt@R\endcsname{#1}%
\ifnum\cnt@R=\pars@R\let\nxt@R\relax\else\let\nxt@R\assign@R\fi\nxt@R}%

{\catcode`|=\active
\gdef|#1 {\global\advance\cnt@R by 1
         \expandafter\xdef\csname REC@\the\cnt@R\endcsname{\csname#1\endcsname}}
}

\def\INalign{\gdef\noalign@R##1{\noalign{##1}}}

\long\def\record#1#2#3#4{\gdef\noalign@R##1{##1}\global\task@R={#4}%
#1%switch to tab
\immediate\openin\lst@R=#3.lst \message{(#3.lst}%
\cnt@R=0
{\catcode`|=\active \global\read\lst@R to \pre@m}%
\message{preamble }%
\pre@m
\ifnum\cnt@R=0 \errhelp{Please insert  |foo  commands in the preamble of
                        your *.lst-file.}%
               \errmessage{No parameters given!}\fi
\xdef\pars@R{\the\cnt@R}\global\cntr@R=#2 \global\cntpb@R=0
\global\RECnumber=0
\dorecord@R
%\message{)}%
\noalign@R{\immediate\closein\lst@R}}

\def\all{10000}%
\def\pagebreakafter#1{\gdef\pba@R{#1}}
\pagebreakafter\all

\endinput
