From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from cgl.ntg.nl (Cgl.ntg.nl [5.39.185.202]) by inbox.vuxu.org (Postfix) with ESMTP id 37E222EC4A for ; Thu, 17 Oct 2024 03:16:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 6E320484FF7 for ; Thu, 17 Oct 2024 03:16:47 +0200 (CEST) Authentication-Results: cgl.ntg.nl (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=ntg.nl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntg.nl; h= content-type:content-type:list-unsubscribe:list-subscribe :list-post:list-owner:list-help:list-archive:archived-at:list-id :subject:subject:reply-to:precedence:in-reply-to:from:from :content-language:references:user-agent:mime-version:date:date :message-id:received:received:received:received:received :received; s=cgl; t=1729127804; x=1731719805; bh=dZxIEfGVyeBfSfA 2WSI20zcoDFaoEOwDJ1BUJGOb5oM=; b=eOp3QAQXxG5Uok+Eiord5557lz6vgZR +lFn8gSeTygMUePHacSw7kr/QPpw95bvwLCy4GG6xCaOCNIGJ47ZlTwIEAUH5Xer YX8HgMAQuTLoF4qsrisKbpr7GKStjKOQq336jbraW2ZZCMGTyX5/fKQWl1oA2kwI pqFjOuNHvYdA= X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2Wx3l9KfJKvP for ; Thu, 17 Oct 2024 03:16:44 +0200 (CEST) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id A66AE485927 for ; Thu, 17 Oct 2024 03:08:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 2A14B48570E for ; Thu, 17 Oct 2024 03:07:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mlbyIxIs6vTF for ; Thu, 17 Oct 2024 03:07:34 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=166.84.1.89; helo=mailbackend.panix.com; envelope-from=context@rik.users.panix.com; receiver= Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cgl.ntg.nl (Postfix) with ESMTPS id C4B6748570C for ; Thu, 17 Oct 2024 03:07:34 +0200 (CEST) Received: from [192.168.5.71] (syn-024-194-002-237.res.spectrum.com [24.194.2.237]) by mailbackend.panix.com (Postfix) with ESMTPSA id 4XTV786FN4z4GpF for ; Wed, 16 Oct 2024 21:07:32 -0400 (EDT) Message-ID: <2cbbf3a5-27e5-4ce9-91f2-d52eebbeca8a@rik.users.panix.com> Date: Wed, 16 Oct 2024 21:07:32 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta To: ntg-context@ntg.nl References: <8b8380f8-fcaa-483b-bfd8-dfc4cf554d6e@rik.users.panix.com> <95601b3f-d481-a307-ec4f-5226eebcebf4@gmail.com> Content-Language: en-US From: Rik Kabel In-Reply-To: <95601b3f-d481-a307-ec4f-5226eebcebf4@gmail.com> Message-ID-Hash: AALTAPHUJ3NEA7FGBODWNWRTV7NXI5VC X-Message-ID-Hash: AALTAPHUJ3NEA7FGBODWNWRTV7NXI5VC X-MailFrom: ConTeXt@rik.users.panix.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list Reply-To: mailing list for ConTeXt users Subject: [NTG-context] Re: Low-level macro help needed List-Id: mailing list for ConTeXt users Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: multipart/mixed; boundary="===============0222777072666653800==" This is a multi-part message in MIME format. --===============0222777072666653800== Content-Type: multipart/alternative; boundary="------------lgejpN9Y7UH56SFOjRbK0c1E" Content-Language: en-US This is a multi-part message in MIME format. --------------lgejpN9Y7UH56SFOjRbK0c1E Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On 2024-10-16 17:48, Wolfgang Schuster wrote: > Rik Kabel schrieb am 16.10.2024 um 23:18: >> > > When you have argument after square brackets you have to use #: to=20 > continues scanning for arguments of the command. For the mandatory=20 > argument you should just use #2 and keep #=3D for the optional argument= s=20 > which are only used when text enclosed in curly braces appears. The #*=20 > between the third and fourth argument allows spaces between them. > > %%%% begin example > \tolerant\protected\def\Bi[#1]#:#2#*#=3D#*#=3D% > =C2=A0 {(1=3D#1)% > =C2=A0=C2=A0 (2=3D#2)% > =C2=A0=C2=A0 (3=3D#3)% > =C2=A0=C2=A0 (4=3D#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=20 > \ifparameter command with the parameter to check (i.e. #1) as argument=20 > (don't forget the \or) but \doifempty etc. work as well. > > %%%% begin example > \tolerant\protected\def\Bi[#1]#:#2#*#=3D#*#=3D% > =C2=A0 {\ifparameter#1\or > =C2=A0=C2=A0=C2=A0=C2=A0 First argument is used. > =C2=A0=C2=A0 \else > =C2=A0=C2=A0=C2=A0=C2=A0 First argument is missing or empty. > =C2=A0=C2=A0 \fi} > > \starttext > > \Bi {bar} > > \Bi [] {bar} > > \Bi [foo] {bar} > > \stoptext > %%%% end example > > Wolfgang > _______________________________________________________________________= ____________=20 > > If your question is of interest to others as well, please add an entry=20 > to the Wiki! > > maillist : ntg-context@ntg.nl /=20 > https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl > webpage=C2=A0 : https://www.pragma-ade.nl / https://context.aanhet.net=20 > (mirror) > archive=C2=A0 : https://github.com/contextgarden/context > wiki=C2=A0=C2=A0=C2=A0=C2=A0 : https://wiki.contextgarden.net > _______________________________________________________________________= ____________=20 > Excellent, and thank you for the explanation. I guess #? is still availab= le. (I had tried with #:, but not in combination with [#1] and #=3D for the=20 last parameter). --=20 Rik --------------lgejpN9Y7UH56SFOjRbK0c1E Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


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 #=3D 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#*#=3D#*#=3D%
=C2=A0 {(1=3D#1)%
=C2=A0=C2=A0 (2=3D#2)%
=C2=A0=C2=A0 (3=3D#3)%
=C2=A0=C2=A0 (4=3D#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#*#=3D#*#=3D%
=C2=A0 {\ifparameter#1\or
=C2=A0=C2=A0=C2=A0=C2=A0 First argument is used.
=C2=A0=C2=A0 \else
=C2=A0=C2=A0=C2=A0=C2=A0 First argument is missing or empty.
=C2=A0=C2=A0 \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/n= tg-context.ntg.nl
webpage=C2=A0 : https://www.pragma-ade.nl / https://context.aanhet.n= et (mirror)
archive=C2=A0 : https://github.com/contextgarden/contex= t
wiki=C2=A0=C2=A0=C2=A0=C2=A0 : 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 #=3D fo= r the last parameter).

--
Rik

--------------lgejpN9Y7UH56SFOjRbK0c1E-- --===============0222777072666653800== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============0222777072666653800==--