![](https://secure.gravatar.com/avatar/44ca9eda7aaa681c0e3b3e90125c56b0.jpg?s=120&d=mm&r=g)
Taco Hoekwater schrieb:
Peter Rolf wrote:
I have written such a macro, but sadly it crashes when used inside \color or \definecolor. Tried to debug it, but this is my first experience with the trace commands (probably not the best example to start with). Sigh, still so much to learn.. :)
The problem is that it defines things, and you can't do that inside an argument. Solution: rewrite the macro to define a new macro (like \def\currentStateDependentColor{green}) instead of expanding on the fly. Then you have to do something like this:
\StateDependentColor[stateA=green,stateC=blue,whatever=yellow,...] \ color[\currentStateDependentColor]
And that should work.
:)) THANK YOU TACO!!! Best wishes, Peter
Best wishes, Taco ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
\setuppagenumber[state=stop] \setupcolors[state=start] \definecolor[colorA] [red] \definecolor[colorB] [green] \definecolor[colorC] [blue] \newconditional\CondA \newconditional\CondB \newconditional\CondC \unprotect \def\CurrentStateDependentColor{} \def\GetStateDependentColor#1% {\bgroup \rawgetparameters[SDC@][A=,B=,C=,#1]% \def\docommand##1% {\doifdefined{Cond##1} % conditional is known.. {\expandafter\ifconditional\csname Cond##1\endcsname % ..AND true.. \doifsomething{\csname SDC@##1\endcsname} % ..AND a color is assigned \donetrue \else\donefalse\fi}% \ifdone\xdef\CurrentStateDependentColor{\csname SDC@##1\endcsname}% \expandafter\quitcommalist\fi}% \processcommacommand[A,B,C]\docommand % raw version does not work! why? \egroup} \protect \starttext %\settrue\CondA \settrue\CondB \settrue\CondC %\tracingonline=1 %\tracingall=1 %\tracingmacros=1 %\tracingcommands=2 \GetStateDependentColor{A=colorA,C=colorC} %\definecolor[testcolor][\TESTcolor] \switchtocolor[\CurrentStateDependentColor] %\tracingmacros=0 %\tracingall=0 THANK YOU TACO!!! \stoptext