Changes

Jump to navigation Jump to search
Create entire page
{{Reference
|name=dodoublegroupempty
|attributes=
}}

== [[Help:Reference|Syntax]] ==
<table cellspacing="4" cellpadding="2" class="cmd">
<tr>
<td colspan="2" class="cmd">\dodoublegroupempty''\commmand''<!--
--></td>
</tr>
</table>

== Description ==

{{cmd|dodoublegroupempty}} is used to write commands that can take zero, one, or two arguments in braces: if the user specifies less than two arguments, it adds empty arguments at the end to make up the missing numbers.

So, <tt>\dodoublegroupempty\command</tt> leads to:

\command{#1}{#2} % or
\command{#1}{} % or
\command{}{} % ,

depending on the generosity of the user. Afterwards one can
use the {{cmd|iffirstargument|link=no}}, {{cmd|ifsecondargument|link=no}}, ... tests to determine how many arguments were actually passed.

There are variants of this command that will supply anywhere up to seven optional arguments:
* <tt>\dosinglegroupempty</tt>
* <tt>\dodoublegroupempty</tt>
* <tt>\dotriplegroupempty</tt>
* <tt>\doquadruplegroupempty</tt>
* <tt>\doquintuplegroupempty</tt>

== Example ==

This is the standard pattern for writing a command that takes an optional number of arguments in braces:

<context mode=mkiv>
% This command accepts two optional arguments
\def\writename%
{\dodoublegroupempty
\dowritename}

% This command looks at how many non-empty arguments
% are supplied, and acts accordingly
\def\dowritename#1#2%
{\ifsecondargument
Ms. #2 (first name #1)%
\else\iffirstargument
Ms. #1%
\else
No name supplied.%
\fi\fi}

\writename{Snow}{White} \par
\writename{White} \par
\writename
</context>

== See also ==
* [[Commands with optional arguments]]
* {{src|syst-aux.mkiv}}
* {{cmd|dodoubleempty}}

== Help from ConTeXt-Mailinglist/Forum ==
All issues with:
{{Forum|dodoublegroupempty}}

[[Category:Command/Internals|dodoublegroupempty]]

Navigation menu