<HTML>
<FONT style="FONT-FAMILY: tahoma; FONT-SIZE: 10pt">
<DIV>Thanks for the help. It worked. However when I read each line by
\readline, I get a comma at the end of each line. How can I get rid of
the comma. Best regards, S. N. Hosseini.<BR> </DIV></FONT><BR>
<BLOCKQUOTE style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px;
PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">-----Original
Message-----<BR>From: "Philip Taylor (Webmaster, Ret'd)"
<P.Taylor@Rhul.Ac.Uk><BR>To: Seyed Naser Hoseini
<nhoseini@mail.uk.ac.ir><BR>Cc: support@tug.org<BR>Date: Sat, 25 Dec
2010 22:36:31 +0000<BR>Subject: Re: [texhax] A couple of questions<BR><BR>
<DIV style="FONT-FAMILY: monospace, courier new, courier"><BR><BR>Seyed
Naser Hoseini wrote:<BR><BR>> Dear Lady/Gentleman: I am writing a macro
in tex but it is not working.<BR>> This is what I want to do:<BR>> I
have a tex file A.tex. In another file, B.tex, I want to read A.tex<BR>>
line by line. First problem is when I read the file to, say \a (a token<BR>
> variable), it does not read some of tex characters such as %. I want
to<BR>> read everything on the line including all the characters.<BR><BR>
For this, e-TeX is to be preferred; you will then be able to make use<BR>of
\readline, which is defined as follows :<BR><BR>"\readline is analogous to
\read, but treats each character as if it<BR> were currently of
\catcode 10 (space) or 12 (other); the text thus<BR> read is therefore
suitable for being scanned and re-scanned<BR> (using \scantokens,
q.v.) under different \catcode régimes."<BR><BR>> Now suppose I<BR>>
am reading the first line to \a and the second line to \b. I would like<BR>
> to compare \a and \b and get a true value if they are equal. I am
using<BR>> the following macro unsuccesfully.<BR>> \newif\ifthesame<BR>
>
\def\isthesame#1#2{\def\one{#1}\def\two{#2}\ifx\one\two\thesametrue\else\thesamefalse}<BR>
> I always get false for \isthesame{\a}{\b}, even when the two have
the<BR>> same values!<BR>> I appreciate your help.<BR><BR>I think you
want something like this (for B)<BR><BR>\newread \A<BR>\openin \A = A<BR>
\loop<BR> \readline \A to \a<BR>
\unless \ifeof \A<BR> \readline \A to
\b<BR> \else<BR> \let \b
= \empty<BR> \fi<BR> a: \a \endgraf<BR>
b: \b \endgraf<BR> \ifx \a \b
Success\endgraf \else Failure\endgraf \fi<BR>\unless<BR>
\ifeof \A<BR>\repeat<BR>\end<BR><BR>and here is some sample text (for
A)<BR><BR>Now is the time for all good men to come to the aid of the
party<BR>Now is the time for all good men to come to the aid of the party<BR>
Now is the time for some good men to come to the aid of the party<BR>Now is
the time for all good men to come to the aid of the party<BR>Now is the time
for some good men to come to the aid of the party<BR>Now is the time for
some good men to come to the aid of the party<BR><BR>Philip Taylor<BR></DIV>
</BLOCKQUOTE>
</HTML>