* [NTG-context] Optional delimited arguments with key-value sets?
@ 2025-04-23 15:33 G.C.H.M. Verhaag via ntg-context
2025-04-23 19:20 ` [NTG-context] " Wolfgang Schuster
0 siblings, 1 reply; 3+ messages in thread
From: G.C.H.M. Verhaag via ntg-context @ 2025-04-23 15:33 UTC (permalink / raw)
To: ntg-context; +Cc: G.C.H.M. Verhaag
[-- Attachment #1.1: Type: text/plain, Size: 618 bytes --]
Hi ConTeXt users,
I'm trying to build a user-defined command called *mycommand* and
followed the hints on
(https://wiki.contextgarden.net/ConTeXt_and_Lua_programming/Tutorials/System_Macros/Handling_Arguments)
\def\dodefinemycommand[#1][#2]% {\getparameters[\??xx#1][#2]}
\def\mycommand%
{\dodoubleargumentwithset\dodefinemycommand\strut\blank[2*big] See what
happens: \@@xxonex}
and call it with:
*\mycommand[one,two][x=1,y=2]*
**
This yields a fatal error; while I'd expect something like:
*See what happens: 1*
What am I doing wrong here?
**
**
Gerard
P.S. Currently using version: 2023.02.14 17:44!
[-- Attachment #1.2: Type: text/html, Size: 2752 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* [NTG-context] Re: Optional delimited arguments with key-value sets?
2025-04-23 15:33 [NTG-context] Optional delimited arguments with key-value sets? G.C.H.M. Verhaag via ntg-context
@ 2025-04-23 19:20 ` Wolfgang Schuster
2025-04-24 12:40 ` Gerard Verhaag via ntg-context
0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2025-04-23 19:20 UTC (permalink / raw)
To: ntg-context
Am 23.04.2025 um 17:33 schrieb G.C.H.M. Verhaag via ntg-context:
> Hi ConTeXt users,
>
> I'm trying to build a user-defined command called *mycommand* and
> followed the hints on (https://wiki.contextgarden.net/
> ConTeXt_and_Lua_programming/Tutorials/System_Macros/Handling_Arguments)
>
> \def\dodefinemycommand[#1][#2]% {\getparameters[\??xx#1][#2]}
>
> \def\mycommand%
> {\dodoubleargumentwithset\dodefinemycommand\strut\blank[2*big] See what
> happens: \@@xxonex}
>
> and call it with:
>
> *\mycommand[one,two][x=1,y=2]*
>
> **
>
> This yields a fatal error; while I'd expect something like:
>
> *See what happens: 1*
>
> What am I doing wrong here?
You can't use ? or @ as part of command names unless you use \unprotect
.. \protect when you create and access them. In the following example
the first \@@test command which is placed in the protect works as
expected but the second fails because TeX treats only \@ as command
(which doesn't exists and results in an error) and everything afterwads
(i.e. @test) is simple text.
%%%% begin example
\starttext
\unprotect
\def\@@test{[test]}
A\@@test B
\protect
A\@@test B
\stoptext
%%%% end example
Below is a simple definition of \mycommand which uses the old method to
create optional arguments. There are better ways to achieve the same
result with newer ConTeXt versions but you didn't provide enough
information about your goal.
%%%% begin example
\starttext
\protected\def\mycommand
{\dodoubleargument\domycommand}
\def\domycommand[#1][#2]%
{\def\dodomycommand##1{\getparameters[mycommand##1][#2]}%
\processcommalist[#1]\dodomycommand
%
See what happens: \getvalue{mycommandonex}}
\mycommand[one,two][x=1,y=2]
\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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* [NTG-context] Re: Optional delimited arguments with key-value sets?
2025-04-23 19:20 ` [NTG-context] " Wolfgang Schuster
@ 2025-04-24 12:40 ` Gerard Verhaag via ntg-context
0 siblings, 0 replies; 3+ messages in thread
From: Gerard Verhaag via ntg-context @ 2025-04-24 12:40 UTC (permalink / raw)
To: ntg-context; +Cc: Gerard Verhaag
Hi Wolfgang,
Thanks for your explanation; but I was unable to grasp it, sorry!
I don't have an application for it yet, but simply followed the wiki manual page to find out whether I could use this feature.
Being unable to figure out why it didn't work, I decided to ask this question.
Being a simple user of ConTeXt, I consider all this far too complicated, and have decided not to dig any deeper. My eyes don't allow very much screen work, due to my old age. Spending too much time at the computer screen isn't an option for me anymore!
But I appreciate your effort in trying to help me understand it!
Regards,
Gerard
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-24 12:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-23 15:33 [NTG-context] Optional delimited arguments with key-value sets? G.C.H.M. Verhaag via ntg-context
2025-04-23 19:20 ` [NTG-context] " Wolfgang Schuster
2025-04-24 12:40 ` Gerard Verhaag via ntg-context
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).