[NTG-context] optional arguments, if(nth)argument

Henning Hraban Ramm hraban at fiee.net
Thu Jan 6 20:24:47 CET 2005


Hello again!

Today I'm trying a lot of new (to me) things...
This time, a macro with optional arguments and \if...argument :

\def\SkillField{\dodoubleempty\doSkillField}

\def\doSkillField[#1][#2]#3{\bTR\bTD #3
	\iffirstargument\hfill (#1)\fi     % don't print when no optional 
argument
	\eTD \bTD
	\ifsecondargument                  % if second optional arg is provided
		\definefield[#2][line][Skill][#1]\field[#2]
	\else                              % if no second optional arg
		\definefield[#3][line][Skill][#3]\field[#3]
	\fi
	\eTD\eTR}

e.g.
\SkillField[+8][Aergern]{Ärgern} % works
\SkillField[+1]{Labern} % does nothing instead of "else"
\SkillField{Testen} % does "\hfill (#1)", but should do nothing

Apparently, the \if...argument ... \else don't work as they should.
Where's my mistake?


Grüßlis vom Hraban!
---
http://www.fiee.net/texnique/
http://contextgarden.net


More information about the ntg-context mailing list