From: Rik Kabel <ConTeXt@rik.users.panix.com>
To: ntg-context@ntg.nl
Subject: [NTG-context] Re: Low-level macro help needed
Date: Wed, 16 Oct 2024 21:07:32 -0400 [thread overview]
Message-ID: <2cbbf3a5-27e5-4ce9-91f2-d52eebbeca8a@rik.users.panix.com> (raw)
In-Reply-To: <95601b3f-d481-a307-ec4f-5226eebcebf4@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 2142 bytes --]
On 2024-10-16 17:48, Wolfgang Schuster wrote:
> Rik Kabel schrieb am 16.10.2024 um 23:18:
>> <stuff deleted for brevity in replying.>
>
> When you have argument after square brackets you have to use #: to
> continues scanning for arguments of the command. For the mandatory
> argument you should just use #2 and keep #= for the optional arguments
> which are only used when text enclosed in curly braces appears. The #*
> between the third and fourth argument allows spaces between them.
>
> %%%% begin example
> \tolerant\protected\def\Bi[#1]#:#2#*#=#*#=%
> {(1=#1)%
> (2=#2)%
> (3=#3)%
> (4=#4)}
>
> \starttext
>
> [\Bi[one]{two}{three}{four}]
>
> [\Bi [one] {two} {three} {four}]
>
> [\Bi [one] {two} {three}]
>
> [\Bi [one] {two}]
>
> [\Bi {two}]
>
> [\Bi [one] {two}]
>
> \stoptext
> %%%% end example
>
> To check whether a argument is empty or not you can use the
> \ifparameter command with the parameter to check (i.e. #1) as argument
> (don't forget the \or) but \doifempty etc. work as well.
>
> %%%% begin example
> \tolerant\protected\def\Bi[#1]#:#2#*#=#*#=%
> {\ifparameter#1\or
> First argument is used.
> \else
> First argument is missing or empty.
> \fi}
>
> \starttext
>
> \Bi {bar}
>
> \Bi [] {bar}
>
> \Bi [foo] {bar}
>
> \stoptext
> %%%% end example
>
> Wolfgang
> ___________________________________________________________________________________
>
> If your question is of interest to others as well, please add an entry
> to the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage : https://www.pragma-ade.nl / https://context.aanhet.net
> (mirror)
> archive : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___________________________________________________________________________________
>
Excellent, and thank you for the explanation. I guess #? is still available.
(I had tried with #:, but not in combination with [#1] and #= for the
last parameter).
--
Rik
[-- Attachment #1.2: Type: text/html, Size: 3891 bytes --]
[-- Attachment #2: Type: text/plain, Size: 511 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
prev parent reply other threads:[~2024-10-17 1:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-16 21:18 [NTG-context] " Rik Kabel
2024-10-16 21:48 ` [NTG-context] " Wolfgang Schuster
2024-10-17 1:07 ` Rik Kabel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2cbbf3a5-27e5-4ce9-91f2-d52eebbeca8a@rik.users.panix.com \
--to=context@rik.users.panix.com \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).