[NTG-context] How to \processcommalist inside another commalist?
Hans Hagen
pragma at wxs.nl
Mon Aug 21 23:08:59 CEST 2006
nico wrote:
> On Mon, 21 Aug 2006 20:35:27 +0200, Mojca Miklavec
> <mojca.miklavec.lists at gmail.com> wrote:
>
>
>>> %% Why using parameter for this?
>>>
>> I was sure that someone would ask that. I want to provide optional
>> parameters for both numbers and scaling:
>> \useGNUPLOTgraphic[name]
>> or
>> \useGNUPLOTgraphic[name][width=.9\textwidth]
>> or
>> \useGNUPLOTgraphic[name][n={1,3}]
>> or
>> \useGNUPLOTgraphic[name][n={1,3},width=.9\textwidth]
>>
>> but after some thinking I realized that it would indeed be a better
>> idea (less to type?) to have
>> \useGNUPLOTgraphic[name][1,3]
>> and
>> \useGNUPLOTgraphic[name][1,3][width=.9\textwidth]
>> instead.
>>
>> At the beginning the main reason against it was that I didn't know how
>> to distinguish which kind of parameters are being used in the second
>> pair of brackets, but I guess that I can safely use \ifnumberelse as a
>> test on the first item to distinguish between the two.
>>
>
> Maybe you could play only with the parameter count. The limitation is that
> an empty second argument is required when only options need to be passed.
>
why? in that case #3 is empty and #2 contains the options
> \def\printPrime#1{#1 is prime.\crlf}
>
> \def\useGNUPLOTgraphic
> {\dotripleempty\douseGNUPLOTgraphic}
>
> \def\douseGNUPLOTgraphic[#1][#2][#3]%
> {\ifthirdargument
> \doprime{#2}
> parameters are #3
> \getparameters[gnuplot][#3]
> \else\ifsecondargument
> \doprime{#2}
> \fi\fi}
>
> \def\doprime#1{\processcommalist[#1]\printPrime}
>
> \starttext
> \useGNUPLOTgraphic[name]
> \useGNUPLOTgraphic[name][2,3,5]
> \useGNUPLOTgraphic[name][3,5,7][width=2in]
> \useGNUPLOTgraphic[name][][width=4in]
> \stoptext
>
> Regards,
> BG
> _______________________________________________
> ntg-context mailing list
> ntg-context at ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
More information about the ntg-context
mailing list