![](https://secure.gravatar.com/avatar/44ca9eda7aaa681c0e3b3e90125c56b0.jpg?s=120&d=mm&r=g)
Henning Hraban Ramm wrote:
Am 2005-10-18 um 10:23 schrieb Peter Rolf:
I tried to write a macro for a TABLE line:
\def\TestCmd{\dodoubleempty\doTestCmd} \def\doTestCmd[#1][#2]#3{\bTR\bTD #3 \iffirstargument\hfill (#1)\fi \eTD \bTD \ifsecondargument 3: #2 and #3 \else 2: only #3 \fi \eTD\eTR }
But it never goes into "else" (if #2 is empty, I get "3: and #3")! And it's only with the table commands around. Why? What can I do?
the numbering is not bound to the parameter number; it's just a counter. calling the macro with two arguments -> \iffirstargument is true \ifsecondargument is true \ifthirdargument is false
sorry, my fault. you are right :) the numbers are bound to the parameter. and \ifthirdargument is always true (not an optional parameter). ----- \def\TestCmd{\dodoubleempty\doTestCmd} \def\doTestCmd[#1][#2]#3{% \ifsecondargument \iffirstargument 3(#1/#2/#3) \else 2a(#1.#2.#3) \fi \else \iffirstargument 2b(#1/#2/#3) \else 1(#1/#2/#3) \fi \fi } \starttext \TestCmd{C} \TestCmd[A]{C} \TestCmd[][B]{C} \TestCmd[A][B]{C} \stoptext ----- this gives 1(//C) 2b(A//C) 3(/B/C) 3(A/B/C) thanks for the lesson ;) Peter
But why *does it work* without the TABLE commands??
??? maybe an expansion problem. have you tried \expanded{\TestCmd...}
If it would be true (or at least the reason for my problem) what you wrote, the following should work:
\def\TestCmd{\dodoubleempty\doTestCmd} \def\doTestCmd[#1][#2]#3{\bTR\bTD #3 \ifsecondargument \iffirstargument\hfill (#1)\fi \eTD \bTD 3(#1.#2.#3) \else \iffirstargument\hfill (#1)\fi \eTD \bTD 2(#1/#2/#3) \fi \eTD\eTR }
But there I get only a ! Incomplete \iftrue; all text was ignored after line 63. <inserted text> \fi
Grüßlis vom Hraban! --- http://www.fiee.net/texnique/ http://contextgarden.net http://www.cacert.org (I'm an assurer)
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context