On Thursday 05 February 2009 01:36:16 pm Wolfgang Schuster wrote:
Am 05.02.2009 um 21:26 schrieb Bart C. Wise:
When a function is called, I would like to remove any leading space. Then the function can control the spacing. If I don't remove spaces, it then makes a difference whether or not I have a space before the function is called.
Is there a way to do this and not cause any side effects?
You can use \removeunwantedpsaces to remove preceding spaces before your command and \ignorespaces to gobble spaces after your command.
A faster version of your macro is:
\def\MyFunction {\dosingleempty\doMyFunction}
\def\doMyFunction[#1]% {\removeunwantedspaces\executeifdefined{myfunction:#1} {\getvalue{myfunction:default}}}
\setvalue{myfunction:1}{\medspace dog } \setvalue{myfunction:2}{\medspace cat } \setvalue{myfunction:default}{\ldots}
Thanks Wolfgang for the answer! And thanks for the coding hints, they are always appreciated! Bart