Path: utzoo!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!aunro!aupair.cs.athabascau.ca!atha!decwrl!uunet!brunix!gvr From: gvr@cs.brown.edu (George V. Reilly) Newsgroups: comp.text.tex Subject: Re: Testing for null arguments Keywords: latex Message-ID: <68473@brunix.UUCP> Date: 14 Mar 91 00:23:46 GMT References: <5396@vela.acs.oakland.edu> Sender: news@brunix.UUCP Reply-To: gvr@cs.brown.edu (George V. Reilly) Organization: Brown University, Dept. of Computer Science Lines: 61 In article <5396@vela.acs.oakland.edu> rjohnson@vela.acs.oakland.edu (R o d Johnson) writes: | | This is undoubtedly a question with a simple answer that I just can't | seem to get. I want to have a macro (for use in LaTeX documents) that | can have three arguments, two of which can be null. It's invoked like | this: | | \prt{arg1}{arg2}{arg3} | | but could also look like any of the following: | | \prt{}{arg2}{arg3} | \prt{arg1}{arg2}{} | \prt{}{arg2}{} | | (arg2 will always be present). I want to define an new \if (I guess) | that would allow me to define a macro like the following: | | \def\part#1#2#3{% % or should there be braces around | [some code] % the arguments in the definition? | % | \ifnull{#1} \relax \else % I guess it would be simpler to have | [some more code] % an \ifnotnull to do this | \fi | % | \ifnull{#3} \relax \else | [some more code] | \fi | } | | I just can't figure out how to come up with an \ifnull or \ifnotnull. | Any suggestions? Thanks in advance. Try this: \def\part#1#2#3{% \def\first{#1} % Or something with more mnemonic value \def\third{#1} [some code] % \ifx\first\empty % do nothing \else [some more code] \fi [etc.] } You might find it more convenient to define \part using strings to delimit the three arguments, e.g.: \def\part #1:#2:#3!{%... so you can say \part :arg2:! or \part :arg2:arg3! or \part arg1:arg2:! or \part arg1:arg2:arg3! or you can use multicharacter strings instead of the `:'s and the `!', of course. ________________ George V. Reilly `LiveLong&Fester' gvr@cs.brown.edu +1 (401) 863-7684 uunet!brunix!gvr gvr@browncs.bitnet Box 1910, Brown U, Prov, RI 02912