Hallo ConTeXters,
I am playing with defining my own macro with key=value parameters.
Please, consider definition:
\def\setupField[#1]#2[#3]{\getparameters[Field!#1!][#3]}
\setupField[name][mykey=value,textwidth=2cm]
If you let ConTeXt to show the values by
\message{
}
you obtain
While 'mykey' is OK, predefined keys (like textwidth, text, style, ...)
lead to undefined parameter, that behave like \relax.
I can imagine next solutions:
1) Do not use predefined keys in my macros, e.g. textWidth instead of
textwidth [=user unfriendly].
2) Use original (mostly Dutch) keys inside of my macros
[=developer unfriendly].
3) Define:
\unprotect
\def\getparametersALL{\dogetparameters\dosetvalueALL}
\def\dosetvalueALL#1#2{\@EA\def\csname#1#2\endcsname}
\protect
and use:
\def\setupField[#1]#2[#3]{\getparametersALL[Field!#1!][#3]}
\setupField[name][mykey=value,textwidth=2cm]
\message{
}
it gives:
Is there any other (more elegant and not-so-dirty) solution?
Thankx
Vit Zyka