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
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
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/
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
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 -----------------------------------------------------------------
participants (3)
-
Aditya Mahajan
-
Hans Hagen
-
Peter Münster