[comp.text] TeX macro question

len@rufus.math.nwu.edu (Len Evens) (11/30/89)

I am trying to understand the first example in The TeXbook in Appendix E.
(This is a set of macros for a business letter format with a letterhead.)
It contains the following code

\def\address{\beginlinemode\getaddress}
{\obeylines\gdef\getaddress #1
 #2
{#1\gdef\addressee{#2}%
etc.

This seems to be a fairly common kind of construction.   In use,
the block of lines following `\address' in a source file becomes an
argument used elsewhere (for example, in making a label); in particular,
the control sequence `\addressee' becomes the first line in the
address.

There seem to be some other examples in Appendix D of the TeXbook with
similar forms, but I haven't been able to find a general description
of why such macros are supposed to work.   In particular, I don't
understand the use of `\getaddress' which is defined in the 2nd and
third lines to have two arguments but which is called without arguments
by \address.

Can anyone either explain this or direct me to a reference which
clarifies the construction?  (It may be somewhere in the TeXbook, but
my usual method of leafing back a forth between the text and the index
has not turned up anything relevant.)

Leonard Evens                      len@math.nwu.edu
Department of Mathematics 
Northwestern University
Evanston, IL 60208
312-491-5537

bts@sas.UUCP (Brian T. Schellenberger) (12/07/89)

[Email bounced . . .]

In article <1706@accuvax.nwu.edu> you write:
|I am trying to understand the first example in The TeXbook in Appendix E.
|(This is a set of macros for a business letter format with a letterhead.)
|It contains the following code
|
|\def\address{\beginlinemode\getaddress}
|{\obeylines\gdef\getaddress #1
| #2
|{#1\gdef\addressee{#2}%
|etc.

TeX works like a MACRO language, so if you use

\address{a}{b}

in your text, then since the definition of address left off with 
\getaddress, it will expand to:

\beginlinemode\getaddress{a}{b}

. . . passing the arguments follow \address to \getaddress.

This is done so that the arguments will be scanned in "linemode."; otherwise,
\getaddress does the work that \address really wants to do.
-- 
-- Brian, the Man from Babble-on.		...!mcnc!rti!sas!bts
-- (Brian Schellenberger)
"No one will ever write a song called 'Nitro Burning Funny Cars'"
                 -- THE DEAD MILKMEN, "Nitro Burning Funny Cars"


-- 
-- Brian, the Man from Babble-on.		...!mcnc!rti!sas!bts
-- (Brian Schellenberger)
"No one will ever write a song called 'Nitro Burning Funny Cars'"
                 -- THE DEAD MILKMEN, "Nitro Burning Funny Cars"