Re: [NTG-context] Define doifoneelse

2006-09-11 Thread Peter Münster
On Mon, 11 Sep 2006, Aditya Mahajan wrote:

 \doifoneelse{1}{a}{b}  gives a
 \doifoneelse{1.5}{a}{b} gives b
 \doifonelese{string}{a}{b} gives b
 
 Can someone suggest how to define this?

\def\doifoneelse#1#2#3{\doifelse{1}{#1}{#2}{#3}}
\starttext
\doifoneelse{1}{a}{b}  gives a
\doifoneelse{1.5}{a}{b}gives b
\doifoneelse{string}{a}{b} gives b
\stoptext

Cheers, Peter

-- 
http://pmrb.free.fr/contact/
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Define doifoneelse

2006-09-11 Thread Aditya Mahajan



On Mon, 11 Sep 2006, Peter M?nster wrote:


On Mon, 11 Sep 2006, Aditya Mahajan wrote:


\doifoneelse{1}{a}{b}  gives a
\doifoneelse{1.5}{a}{b} gives b
\doifonelese{string}{a}{b} gives b

Can someone suggest how to define this?


\def\doifoneelse#1#2#3{\doifelse{1}{#1}{#2}{#3}}


Thanks Peter,

 I ended up using

\def\doifoneelse#1{\doifelse{#1}{1}}

which saves a few keystrokes :)

Aditya___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Define doifoneelse

2006-09-11 Thread Hans Hagen
Aditya Mahajan wrote:


 On Mon, 11 Sep 2006, Peter M�nster wrote:

 On Mon, 11 Sep 2006, Aditya Mahajan wrote:

 \doifoneelse{1}{a}{b}  gives a
 \doifoneelse{1.5}{a}{b} gives b
 \doifonelese{string}{a}{b} gives b

 Can someone suggest how to define this?

 \def\doifoneelse#1#2#3{\doifelse{1}{#1}{#2}{#3}}

 Thanks Peter,

  I ended up using

 \def\doifoneelse#1{\doifelse{#1}{1}}

 which saves a few keystrokes :)
\def\doifoneelse{\doifelse{1}}

or 

\def\doifoneelse{\doifelse1}

saves you even more keystrokes and also a bit of runtime (measured in 
nanoseconds) 

Hans 

-
  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
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] Define doifoneelse

2006-09-10 Thread Aditya Mahajan
Hi,

  I want to define a macro, \doifoneelse, that checks if the first 
argument is 1 or not. It should work for decimals and strings also. 
So,

\doifoneelse{1}{a}{b}  gives a
\doifoneelse{1.5}{a}{b} gives b
\doifonelese{string}{a}{b} gives b

Can someone suggest how to define this?

Thanks,
Aditya

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Define doifoneelse

2006-09-10 Thread Aditya Mahajan
On Mon, 11 Sep 2006, Aditya Mahajan wrote:

 Hi,

  I want to define a macro, \doifoneelse, that checks if the first
 argument is 1 or not. It should work for decimals and strings also.
 So,

 \doifoneelse{1}{a}{b}  gives a
 \doifoneelse{1.5}{a}{b} gives b
 \doifonelese{string}{a}{b} gives b

 Can someone suggest how to define this?

Ah, it is already defined in context. I was so fixated upon using 
\ifnum and \ifcase that I did not see \doifelse. Sorry about the 
noise.

Aditya
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context