[comp.text.tex] TeXbook question Appendix E getaddress macro

wurtz@sgi400.msd.lmsc.lockheed.com (Jeff Wurtz) (05/18/91)

I need someone's help to understand the \getaddress macro in Appendix E,
page 407 of the TeXbook.  Anything you can tell me to assist my understanding
will be greatly appreciated.  I have the following specific questions:
1) What is parameter #1 used for?  My guess is that it is used only to "get
   to the end of line", but if that is so, then why is it used in the
   replacement text?  As best as I can determine, parameter #1 is blank!
2) In the line defining \getaddress, is the \obeylines included only for
   purposes of the macro definition or is it used "outside" of the macro?
3) When \getaddress is used (by \address), only one line (Prof.~Brian~K. Reid)
   goes into parameter #2.  How does \getaddress read paremeter #2?  Does it
   use a <CR> as a delimiter?  Does it use "end of paragraph" as a delimiter?
   What determines the end of the argument for parameter #2?
4) How do the three address lines get into box \theaddress?

Macro \getaddress appears (to me) to be a sophisticated way of specifying
arguments for a macro.  I really want to understand how it works.  The amount
of explanation for this macro in the TeXbook seems woefully inadequate.

Thanks for your help.

dahosek@biivax.dp.beckman.com (05/23/91)

In article <16505@leadsv.UUCP>, wurtz@sgi400.msd.lmsc.lockheed.com (Jeff Wurtz) writes:
> I need someone's help to understand the \getaddress macro in Appendix E,
> page 407 of the TeXbook.  Anything you can tell me to assist my understanding
> will be greatly appreciated.  I have the following specific questions:
> 1) What is parameter #1 used for?  My guess is that it is used only to "get
>    to the end of line", but if that is so, then why is it used in the
>    replacement text?  As best as I can determine, parameter #1 is blank!

Yep. It's pulled to get past the EOL after \address and its
contents are reinserted in the output to guarantee that no text
is lost (see also \closing).

> 2) In the line defining \getaddress, is the \obeylines included only for
>    purposes of the macro definition or is it used "outside" of the macro?

Yes. \obeylines is used to make sure that the catcode of ^^M is
correct when the definition takes place. In the execution,
\obeylines is handled by \beginlinemode in \address which calls
\getlinemode

> 3) When \getaddress is used (by \address), only one line (Prof.~Brian~K. Reid)
>    goes into parameter #2.  How does \getaddress read paremeter #2?  Does it
>    use a <CR> as a delimiter?  Does it use "end of paragraph" as a delimiter?
>    What determines the end of the argument for parameter #2?

It's the ^^M (which is active because of the \obeylines) which
indicates the end of parameter #2.

> 4) How do the three address lines get into box \theaddress?

The box isn't finished off until \endmode is called by \body so
everything from parm #2 on goes into the box. (You may want to
look up \bgroup and \egroup in the index for more insight on
that.)
 
> Macro \getaddress appears (to me) to be a sophisticated way of specifying
> arguments for a macro.  I really want to understand how it works.  The amount
> of explanation for this macro in the TeXbook seems woefully inadequate.

You may want to also examine the \closing/\getclosing macro to
see a similar parsing of text.

-dh

-- 
Don Hosek // Quixote Digital Typography   714-625-0147
     dhosek@ymir.claremont.edu
On contract to Beckman Instruments        714-961-4562
     dahosek@beckman.com