From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/38055 Path: news.gmane.org!not-for-mail From: Peter Rolf Newsgroups: gmane.comp.tex.context Subject: Re: color expansion at runtime Date: Mon, 17 Dec 2007 16:01:02 +0100 Message-ID: <47668F2E.7080702@gmx.net> References: <4762B608.1010107@gmx.net> <47665091.5020407@elvenkind.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010805010104030902020501" X-Trace: ger.gmane.org 1197903785 6364 80.91.229.12 (17 Dec 2007 15:03:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 17 Dec 2007 15:03:05 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Dec 17 16:03:16 2007 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1J4HUb-000620-Th for gctc-ntg-context-518@m.gmane.org; Mon, 17 Dec 2007 16:02:53 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 58F0E1FC7C; Mon, 17 Dec 2007 16:02:16 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 16458-03-6; Mon, 17 Dec 2007 16:01:37 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 8B05A1FBCB; Mon, 17 Dec 2007 16:01:37 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 1615B1FBCB for ; Mon, 17 Dec 2007 16:01:35 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 16498-01-5 for ; Mon, 17 Dec 2007 16:01:01 +0100 (CET) Original-Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by ronja.ntg.nl (Postfix) with SMTP id 4FEDE1FBBA for ; Mon, 17 Dec 2007 16:01:01 +0100 (CET) Original-Received: (qmail invoked by alias); 17 Dec 2007 15:01:01 -0000 Original-Received: from i5387DCF5.versanet.de (EHLO [192.168.1.3]) [83.135.220.245] by mail.gmx.net (mp027) with SMTP; 17 Dec 2007 16:01:01 +0100 X-Authenticated: #24293357 X-Provags-ID: V01U2FsdGVkX1+lHI4BsG6l3O2Vkvc23XzdCezMyaYL2gBkKSZVEf SLvHtQnVYYWwso User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) In-Reply-To: <47665091.5020407@elvenkind.com> X-Enigmail-Version: 0.95.5 X-Y-GMX-Trusted: 0 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:38055 Archived-At: This is a multi-part message in MIME format. --------------010805010104030902020501 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 > ___________________________________________________________________________________ > --------------010805010104030902020501 Content-Type: text/plain; name="statecolor.tex" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="statecolor.tex" \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 --------------010805010104030902020501 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --------------010805010104030902020501--