[comp.text.tex] character substitution macro

golding@neon.Stanford.EDU (Andy Golding) (04/02/91)

I seem to be having trouble writing a macro to do
simple character substitution.  I just want it to
replace all occurrences of forward quote (')
with \char19 and backward quote (`) with \char18.
Also, I want everything in typewriter font.

First I tried it without using a macro:

{\tt\catcode`'=\active\chardef'=19\catcode``=\active\chardef`=18
'toe`nail}

That worked just fine.  Then I tried making it into a LaTeX macro:

\newcommand{\pron}[1]{{\tt\catcode`'=\active\chardef'=19
\catcode``=\active\chardef`=18 #1}}
\pron{'toe`nail}

At that point, I got some error about \inaccessible --
I think it was objecting to my chardefs.  Could someone
please tell me how to fix this?  Thanks a lot!

Andy