From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/38005 Path: news.gmane.org!not-for-mail From: "Wolfgang Schuster" Newsgroups: gmane.comp.tex.context Subject: Re: color expansion at runtime Date: Sat, 15 Dec 2007 11:17:29 +0100 Message-ID: <115224fb0712150217r779279ddo9b264c4fafa00c8d@mail.gmail.com> References: <4762B608.1010107@gmx.net> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1197713940 11939 80.91.229.12 (15 Dec 2007 10:19:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Dec 2007 10:19:00 +0000 (UTC) To: "mailing list for ConTeXt users" Original-X-From: ntg-context-bounces@ntg.nl Sat Dec 15 11:19:10 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 1J3U6w-00034j-DD for gctc-ntg-context-518@m.gmane.org; Sat, 15 Dec 2007 11:19:10 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 98FD11FB7E; Sat, 15 Dec 2007 11:18:42 +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 30202-01-3; Sat, 15 Dec 2007 11:18:03 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 142ED1FB29; Sat, 15 Dec 2007 11:18:03 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id B052F1FB49 for ; Sat, 15 Dec 2007 11:18:01 +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 30202-01-2 for ; Sat, 15 Dec 2007 11:17:30 +0100 (CET) Original-Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.172]) by ronja.ntg.nl (Postfix) with ESMTP id 7A9B51FB29 for ; Sat, 15 Dec 2007 11:17:30 +0100 (CET) Original-Received: by ug-out-1314.google.com with SMTP id q2so1322807uge.50 for ; Sat, 15 Dec 2007 02:17:30 -0800 (PST) Original-Received: by 10.67.19.17 with SMTP id w17mr926054ugi.33.1197713850018; Sat, 15 Dec 2007 02:17:30 -0800 (PST) Original-Received: by 10.67.122.17 with HTTP; Sat, 15 Dec 2007 02:17:29 -0800 (PST) In-Reply-To: <4762B608.1010107@gmx.net> Content-Disposition: inline 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:38005 Archived-At: 2007/12/14, Peter Rolf : > Hi, > > I desperately need runtime defined colors (state dependent) for my > macros. The macros are used with different graphic styles, which is the > reason why I want to avoid any style dependent part inside them. > > To give you an example. I need something like this > > \color[{\StateDependentColor[stateA=green,stateC=blue,whatever=yellow,...]}] > > If flag 'stateA' is true at runtime, then color 'green' is used (and so > on; order is significant). > > 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.. :) > > Any hints are welcome. > > Regards, Peter Hi Peter, can you try this (untested), \chardef\stateA\zerocount \chardef\stateB\plusone \chardef\stateC\plustwo \let\currentstate\stateA \def\statecolor{\ifcase\currentstate red\or green\or blue\fi} \starttext \color[\statecolor]{Currentstate} \let\currentstate\stateB \color[\statecolor]{Currentstate} \let\currentstate\stateC \color[\statecolor]{Currentstate} \stoptext Wolfgang ___________________________________________________________________________________ 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 ___________________________________________________________________________________