[comp.text.tex] defining active characters by number

ajcd@cs.ed.ac.uk (Angus Duggan) (08/11/90)

I'm flummoxed. I've searched through the TeXbook for an answer to this
problem, and tried everything I can think of, but I can't find an answer. I
want to make a character active, and define a macro for it, with only the
number of the character specified (in a count register).

What I'm trying to do is to set up a lot of the character codes from 128--255
to call a common macro, with the number of the character code as a parameter.
I'd prefer to have a loop, something like:

\bgroup % localise \count0
  \count0=161
  \loop
    \expandafter\global\expandafter\catcode\count0=\active
    % \edef active character number \count0 to expand to:
    % {\noexpand\macro{\the\count0}}
    \advance\count0 by 1
  \ifnum\count0<255\repeat
\egroup

The only way I can see of doing this is writing out an auxiliary file, and
re-reading it. Somebody please show me that I'm wrong.

A.
==
Angus Duggan, Department of Computer Science,	| Ignorance of the manual is
University of Edinburgh, JCMB,			| no excuse.
The King's Buildings, Mayfield Road,		| JANET:  ajcd@uk.ac.ed.lfcs
Edinburgh, EH9 3JZ, Scotland.	| OR:  ajcd%lfcs.ed.ac.uk@nsfnet-relay.ac.uk

dhosek@sif.claremont.edu (Hosek, Donald A.) (08/11/90)

In article <157@skye.cs.ed.ac.uk>, ajcd@cs.ed.ac.uk (Angus Duggan) writes...

>I'm flummoxed. I've searched through the TeXbook for an answer to this
>problem, and tried everything I can think of, but I can't find an answer. I
>want to make a character active, and define a macro for it, with only the
>number of the character specified (in a count register).

>What I'm trying to do is to set up a lot of the character codes from 128--255
>to call a common macro, with the number of the character code as a parameter.
>I'd prefer to have a loop, something like:

>\bgroup % localise \count0
>  \count0=161
>  \loop
>    \expandafter\global\expandafter\catcode\count0=\active
>    % \edef active character number \count0 to expand to:
>    % {\noexpand\macro{\the\count0}}
>    \advance\count0 by 1
>  \ifnum\count0<255\repeat
>\egroup

>The only way I can see of doing this is writing out an auxiliary file, and
>re-reading it. Somebody please show me that I'm wrong.

The following ought to work.

\uccode`\~=\count0
\uppercase{\catcode`\~=\active
   \xdef~{\noexpand\macro{\the\count0}}}

I haven't tried it though so I'd appreciate it if someone could
let me know how close I've come.

-dh







---
Don Hosek                       TeX, LaTeX, and Metafont support, consulting 
dhosek@ymir.claremont.edu       installation and production work. 
dhosek@ymir.bitnet              Free Estimates.
uunet!jarthur!ymir              Phone: 714-625-0147
                                finger dhosek@ymir.claremont.edu for more info