\setuppagenumber[state=stop] \setupcolors[state=start] \definecolor[colorA] [red] \definecolor[colorB] [green] \definecolor[colorC] [blue] \newconditional\CondA \newconditional\CondB \newconditional\CondC \unprotect \def\GetStateDependentColor[#1]% {\bgroup \rawgetparameters[SDC@][A=,B=,C=,#1]% \def\MYdocommand##1% {\doifdefined{Cond##1} % conditional is known.. {\expandafter\ifconditional\csname Cond##1\endcsname % ..AND true.. \edef\CurrentColor{\csname SDC@##1\endcsname}\else \def\CurrentColor{}\fi \doifelsenothing\CurrentColor % ..AND a color is assigned \donefalse\donetrue}% \ifdone\CurrentColor\expandafter\quitcommalist\fi}% \processcommacommand[A,B,C]\MYdocommand % raw version does not work! why? \egroup} \protect \starttext \setfalse\CondA \settrue\CondB \settrue\CondC \tracingonline=1 %\tracingall=1 %\tracingmacros=1 %\tracingcommands=2 color is -\GetStateDependentColor[A=colorA,C=colorC]- % works so far %\tracingmacros=0 %\tracingall=0 % crashes %\tracingall=1 %\tracingmacros=1 %\tracingcommands=2 %\definecolor[testcolor][{\GetStateDependentColor[A=colorA,C=colorC]}] %\color[testcolor] %\color[{\GetStateDependentColor[A=colorA,C=colorC]}] %\expandafter\color\expandafter[\expandafter{\GetStateDependentColor[A=colorA,C=colorC]}] %\tracingall=0 TEST \stoptext