# [texhax] Implementing control sequences with key values

Sun Nov 14 14:52:54 CET 2010

Am 14.11.2010 um 14:28 schrieb Vafa Khalighi:

> You can set parameters with keyval or xkeyval packages. Is there any package that you can do the same with commands. So for example, you define a command, say, \direction which has two values RTL and LTR and is used in the following way:
>
> \direction=RTL or
>
> \direction=LTR
>
> Is it possible to implement these kind of control sequences?

Yes but i would recommend i method which fits to the macro package, e.g. \setdirection{LTR} or \setdirection[RTL]

\def\direction#1=#2#3
{\def\currentdirection{#2#3}}

\tracingmacros1

\direction=LTR Direction: \currentdirection\par
\direction=RTL Direction: \currentdirection\par

\vskip\baselineskip

\direction =LTR Direction: \currentdirection\par
\direction =RTL Direction: \currentdirection\par

\vskip\baselineskip

\direction = LTR Direction: \currentdirection\par
\direction = RTL Direction: \currentdirection\par

\bye

Wolfgang