[comp.text.tex] ^^M delimited arguments in a macro?

duty@ariel.its.unimelb.edu.au (Duty Programmer) (10/31/90)

I have the following construction in my file:

\def\test #1 #2 #3\par{blah #1 blah #2 blah #3}

\begingroup \obeylines
\test first second and then this is the third argument
\test first second and then this is the third argument
\test first second and then this is the third argument
\test first second and then this is the third argument
\endgroup

\bye

As I understand it, \obeylines ``makes the ASCII <return> into an
active character that uses the current meaning of \par, and plain TeX
puts <return> at the end of an input line.'' (TeXbook, p.249)

But TeX does not seem to be doing this; I get 'runaway argument' errors
when I process the file. If I put `\par' at the end of each line, it
works fine!

Help!

rab
---
Richard Brown                     | E-mail: rab@ariel.its.unimelb.EDU.AU
School of Physics                 | Phone : +61 3 344 5081
University of Melbourne           | Fax   : +61 3 347 4783
Parkville Victoria AUSTRALIA 3052 | Telex : AA35185

eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) (11/02/90)

duty@ariel.its.unimelb.edu.au (Duty Programmer) writes:

>\def\test #1 #2 #3\par{blah #1 blah #2 blah #3}

>\begingroup \obeylines
>\test first second and then this is the third argument

>As I understand it, \obeylines ``makes the ASCII <return> into an
>active character that uses the current meaning of \par, and plain TeX

Right, but that doesn't mean that there is actually a \par
at the end, there is still a <return>, and if that would
ever be investigated it would assume the meaning of \par,
but not if it just glossed over by a macro scanning for
arguments.

\catcode`\^^M=12
\def\PickToEol{\begingroup\catcode`\^^M=12 \xPickToEol}
\def\xPickToEol #1 #2 #3^^M{ blah blah blah \endgroup}
\catcode`\^^M=5

Victor.

myers@ut-emx.uucp (Eric Myers) (11/02/90)

In article <320@ariel.its.unimelb.edu.au> duty@ariel.its.unimelb.edu.au
(Duty Programmer) writes about something that does not quite work: 
>I have the following construction in my file:
>
>\def\test #1 #2 #3\par{blah #1 blah #2 blah #3}
>
>\begingroup \obeylines
>\test first second and then this is the third argument
>\endgroup

Although \obeylines makes ^^M perform as \par, they are not the same.
You need the ^^M in your definition, and you need \obeylines in force
when you try to see the end of the line.  Hence try it this way:


{\obeylines				% to see ^^M during definition
 \gdef\foo#1 #2 #3
    {\message{1=#1 2=#2 3=#3}}
}

\obeylines				% to see ^^M at end of lines
\foo first second and then this is the third argument
\foo first second and then this is the third argument

\bye

Incidentally, in Plain TeX there is no way, save with grouping,
to turn off \obeylines.  Hence I've found this useful:

\def\unobeylines{\catcode`\^^M=5}	% make ^^M just <return>

-- 
Eric Myers		"Frankie say '\relax'"

Center for Relativity, Department of Physics, University of Texas at Austin
myers@emx.utexas.edu  |   myers@utaphy.bitnet   |   myers@ut-emx.UUCP