Re: [NTG-context] doifsomething vs iffirstargument in TABLE?

2019-09-12 Thread Wolfgang Schuster

Jon Wong schrieb am 12.09.2019 um 15:44:

Hi all,

If I use iffirstargument, the optional (first argument) is always seen as false.

If I use doifsomething, it works, but the “else” part is never executed when it 
should.

MWE:

\starttext

% \def\MyRow{\dosingleempty\doMyRow}
% \def\doMyRow[#1]#2#3#4#5{%
%   \bTR \bTD #2 \eTD %

The \bTD command for the cell content has an optional argument
which changes the value of the firstargument conditional and your
check below uses the result from \bTD.

%   \iffirstargument
% \bTD Replaced! \eTD %
%   \else
% \bTD #3 \eTD %
%   \fi
%   \bTD #4 \eTD \bTD #5 \eTD \eTR
% }

\def\MyRow{\dosingleempty\doMyRow}
\def\doMyRow[#1]#2#3#4#5{%
   \bTR \bTD #2 \eTD %
   \doifsomething{#1}

\doifsomethingelse{#1}

 {\bTD Replaced! \eTD }%
 {\bTD #3 \eTD }%
   \bTD #4 \eTD \bTD #5 \eTD \eTR
}

\bTABLE
\bTABLEbody
\MyRow{A}{B}{C}{D}
\MyRow[optional]{A}{B}{C}{D}
\eTABLEbody
\eTABLE

\stoptext

Wolfgang

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] doifsomething vs iffirstargument in TABLE?

2019-09-12 Thread Jon Wong
Hi all,

If I use iffirstargument, the optional (first argument) is always seen as false.

If I use doifsomething, it works, but the “else” part is never executed when it 
should.

MWE:

\starttext

% \def\MyRow{\dosingleempty\doMyRow}
% \def\doMyRow[#1]#2#3#4#5{%
%   \bTR \bTD #2 \eTD %
%   \iffirstargument
% \bTD Replaced! \eTD %
%   \else
% \bTD #3 \eTD %
%   \fi
%   \bTD #4 \eTD \bTD #5 \eTD \eTR
% }

\def\MyRow{\dosingleempty\doMyRow}
\def\doMyRow[#1]#2#3#4#5{%
  \bTR \bTD #2 \eTD %
  \doifsomething{#1}
{\bTD Replaced! \eTD }%
{\bTD #3 \eTD }%
  \bTD #4 \eTD \bTD #5 \eTD \eTR
}

\bTABLE
\bTABLEbody
\MyRow{A}{B}{C}{D}
\MyRow[optional]{A}{B}{C}{D}
\eTABLEbody
\eTABLE

\stoptext


Regards
Jon

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___