On Wed, Sep 3, 2008 at 4:41 PM, Thomas A. Schmitz
Hi all,
I'm trying to define a macro \Command which can either have four or five arguments. If it has five, I want to define them as
\Command1[#1][#2][#3][#4]{#5}
if it has four, as
\Command2[#1][#2][#3]{4#}
I thought this would be the way to go:
\def\Command{% \doquadrupleempty\doCommand}
\def\doCommand{% \iffifthargument% \doquadrupleargument\Command1% \else% \dotripleargument\Command2% \fi}
but that gives me errors about "too many }s". So I'm wondering: am I on the wrong track? Can this be done at all?
Thanks, and best
Thomas
\def\Commanda {\doquadrupleempty\doCommanda} \def\doCommanda[#1][#2][#3][#4]% {\iffourthargument \def\next{\doCommandafive[#1][#2][#3][#4]}% \else \def\next{\doCommandafour[#1][#2][#3]}% \fi\next} \def\doCommandafive[#1][#2][#3][#4]#5% {five arguments} \def\doCommandafour[#1][#2][#3]#4% {four arguments} \def\Commandb {\doquadrupleempty\doCommandb} \def\doCommandb[#1][#2][#3][#4]% {\iffourthargument \def\next{\dodoCommandb[#1][#2][#3][#4]}% \else \def\next{\dodoCommandb[#1][#2][#3][]}% \fi\next} \def\dodoCommandb[#1][#2][#3][#4]#5% {\doifelsenothing{#4} {four arguments} {five arguments}} \starttext \Commanda[1][2][3][4]{5} \Commanda[1][2][3]{4} \Commandb[1][2][3][4]{5} \Commandb[1][2][3]4 \Commandb[1][2][3][]{4} % feature \stoptext Wolfgang