From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/15605 Path: main.gmane.org!not-for-mail From: Taco Hoekwater Newsgroups: gmane.comp.tex.context Subject: Re: High level user macro (howto?) Date: Mon, 28 Jun 2004 11:32:17 +0200 Organization: Elvenkind Sender: ntg-context-admin@ntg.nl Message-ID: <20040628113217.2efb080b@glenlivet.elvenkind.com> References: <"m2hdtw92rn.fs f"@levana.de> <6.1.1.1.2.20040601200608.01eb9640@server-1> <"m2n032tvs8.fs f"@levana.de> <20040622161300.GA5608@swordfish> <34371.80.58.5.46.1087924408.squirrel@bitmail.bitmailer.com> <0D45B077-C4DA-11D8-972E-000A9595B57C@ensta.fr> <40D944A4.5030402@gmx.de> <43DEE2EE-C510-11D8-972E-000A9595B57C@ensta.fr> <72D4BC80-C612-11D8-9706-0030659899AA@fiee.net> <40DC4CDF.2090904@wxs.nl> <5CAF4C26-C756-11D8-AE54-000A95C38698@chello.fr> Reply-To: ntg-context@ntg.nl NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1088415340 9394 80.91.224.253 (28 Jun 2004 09:35:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 28 Jun 2004 09:35:40 +0000 (UTC) Original-X-From: ntg-context-admin@ntg.nl Mon Jun 28 11:35:34 2004 Return-path: Original-Received: from ref.vet.uu.nl ([131.211.172.13] helo=ref.ntg.nl) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BesY2-0006Lc-00 for ; Mon, 28 Jun 2004 11:35:34 +0200 Original-Received: from ref.ntg.nl (localhost.localdomain [127.0.0.1]) by ref.ntg.nl (Postfix) with ESMTP id 7783F10B59; Mon, 28 Jun 2004 11:35:29 +0200 (MEST) Original-Received: from glenfiddich.elvenkind.com (elvenknd.xs4all.nl [213.84.171.68]) by ref.ntg.nl (Postfix) with ESMTP id 1F64010B52 for ; Mon, 28 Jun 2004 11:32:19 +0200 (MEST) Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by glenfiddich.elvenkind.com (Postfix) with ESMTP id 3B439176CA for ; Mon, 28 Jun 2004 11:30:21 +0200 (CEST) Original-Received: from glenfiddich.elvenkind.com ([127.0.0.1]) by localhost (glenfiddich.elvenkind.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 18928-04 for ; Mon, 28 Jun 2004 11:30:20 +0200 (CEST) Original-Received: from glenlivet.elvenkind.com (glenlivet.elvenkind.com [10.10.0.6]) by glenfiddich.elvenkind.com (Postfix) with SMTP id 5C3085BB5 for ; Mon, 28 Jun 2004 11:30:20 +0200 (CEST) Original-To: ntg-context@ntg.nl In-Reply-To: <5CAF4C26-C756-11D8-AE54-000A95C38698@chello.fr> X-Mailer: Sylpheed version 0.9.11claws (GTK+ 1.2.10; i586-mandrake-linux-gnu) X-Virus-Scanned: by amavisd-new at elvenkind.net Errors-To: ntg-context-admin@ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.0.13 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.comp.tex.context:15605 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:15605 Hi Maurice, The 'key' to the keyval functionality in ConTeXt are two macros called \getparameters and \processaction. Here is a 'quickstart', assuming you want to define \myzigzag: % \unprotect % enable exclamations in macro names \def\myzigzag#1[#2]{%=20 % the #1 makes sure we allow a space before the bracket % \getparameters[ZZ][Dir=3D,Linewidth=3D1pt,Color=3DRed,Width=3D3em,#2] % % Now you have a set of new macros that all start with ZZ.=20 % At least there are \ZZDir,\ZZLinewidth, \ZZColor and \ZZWidth % (these have default values) but possibly others as well,=20 % depending on user input. %=20 % Here's a usage example:=20 % \edef\mywidth{\ZZWidth}% % % If you want to use keyword values, then you also need=20 % to use \processaction. %=20 % Say you want "Dir" to be mandatory and that it=20 % accepts 4 directional keywords, as well as a direct=20 % angle specification. % % I've used all mixed case keywords, because otherwise % you might run into conflicts with the multilingual interface % \expandafter\processaction\expandafter[\ZZDir] [Down =3D>\def\Dir{270}, Left =3D>\def\Dir{180}, Up =3D>\def\Dir{90}, Right =3D>\def\Dir{0}, \s!default =3D>\errorDir,=20 \s!unknown =3D>\checkDir{\ZZDir}] %=20 % \s!default may be triggered because \ZZDir's expansion is=20 % empty unless the user supplied something. % % The first argument to \processaction has to be expanded, % so you need the \expandafter's.q } % for completeness, here is an example definition of \checkDir and % \errorDir: \def\errorDir{% \def\Dir{0}% error recovery \message{Please supply "Dir" argument}% } \def\checkDir#1{% \doifnumberelse {#1} {\def\Dir{#1}} {\message{Invalid "Dir" argument! (#1)}} } \protect % end of definitions On Sat, 26 Jun 2004 11:51:14 +0200, Maurice wrote: > Bonjour =E0 tous, >=20 > One thing is missing in context (or not documented in reference manual?) > is a standard and easy way to build arbitrary parametrised high level=20 > macros. >=20 --=20 groeten, Taco