Hello everybody out there using TeX,
Actually, I wanted to write a LaTeX macro in plain TeX in order to include source code examples with individual modifications like stripping off comments and the first 21 characters in LaTeX documents. My code so far looks as follows:
\documentclass{article}
\edef\hashmark{\string#}
\def\getfirst#1#2\getfirst{\string#1}
\def\gobble#1#2{\expandafter#2}
\newread\myread
\begin{document}
\openin\myread=complete.txt
\newcount\linecount
\global\linecount1
\loop
\unless\ifeof\myread
\read\myread to \myinput
\if\hashmark\expandafter\getfirst\detokenize\expandafter{\myinput}\getfirst
\relax
\else
\newcount\position
\global\position1
{
\loop
\unless\ifnum\position>21
\edef\myinput{\expandafter\gobble\myinput}
\global\advance\position1
\repeat
}
\fi
\global\advance\linecount1
\repeat
\closein\myread
\end{document}
This results in the error message ! Paragraph ended before \gobble was complete.
Unfortunately, this is already for the second time I have to ask for help here, because I'm lacking experience in developing TeX and interpreting the error messages.
All these difficulties in manipulating text input using TeX make me wonder, whether it makes really sense to use TeX to manipulate and trim my source code files instead of say sed, Perl, Python or any other programming language in which I have more experience and allowing for easy text manipulation.
Any contribution to this consideration is appreciated.
listingspackage, which offers various refinement for dealing with stripping out material, special lines and the like. – Joseph Wright Dec 25 '12 at 21:42