ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Henning Hraban Ramm <texml@fiee.net>
Subject: [NTG-context] Re: using command line arguments
Date: Mon, 28 Oct 2024 18:54:49 +0100	[thread overview]
Message-ID: <ede1fab3-2140-bb39-2f8e-508cbc3eefb7@gmail.com> (raw)
In-Reply-To: <12e70d2a-8f19-41ee-add3-442a14b41cb1@fiee.net>

Henning Hraban Ramm schrieb am 28.10.2024 um 16:26:
> Am 28.10.24 um 16:18 schrieb Wolfgang Schuster:
>> Henning Hraban Ramm schrieb am 28.10.2024 um 12:18:
>>> Hi, I’m trying to use a command line argument in parameter names – 
>>> color name in the example below, variable namespace in my actual 
>>> project.
>>> I guess I need more expansion, but where?
>>> Or what’s the problem here?
>>>
>>> """
>>> \setupbodyfont[plex,18pt]
>>>
>>> % set \OEM to the parameter name, fall back to "fiee"
>>> \expanded\define\OEM{\expanded\doifelsedocumentargument{OEM} 
>>> {\expanded\getdocumentargument{OEM}}{fiee}} 
>>
>> \doifelsedocumentargument{OEM}
>>    {\def\OEM{\getdocumentargument{OEM}}}
>>    {\def\OEM{fiee}}
>>
>> or
>>
>> \def\OEM
>>    {\ifempty{\getdocumentargument{OEM}}%
>>       fiee%
>>     \else
>>       \getdocumentargument{OEM}%
>>     \fi}
> 
> Thank you, both works (of course, if you say so…).
> Also in my actual project.
> 
> Can you explain why
> \define\OEM{\doifelsedocumentargument{OEM}{\getdocumentargument{OEM}}{fiee}} 
> 
> doesn’t?

1. \define creates an unexpandable command which can't be used as name 
placeholder for \color.

%%%% begin example
\starttext

\protected\def\GELB{yellow} % \defineexpandable\GELB{...}
           \def\BLAU{blue}   %           \define\BLAU{...}

\color[\GELB]{yellow}

\color[\BLAU]{blue}

\stoptext
%%%% end example

2. The \doifelsedocumentargument command is not expandable as well which 
makes it impossible to use it to pick the correct color name within the 
argument of \color.

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
___________________________________________________________________________________

      reply	other threads:[~2024-10-28 17:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-28 11:18 [NTG-context] " Henning Hraban Ramm
2024-10-28 12:01 ` [NTG-context] " Thomas A. Schmitz
2024-10-28 12:41   ` Henning Hraban Ramm
2024-10-28 15:18 ` Wolfgang Schuster
2024-10-28 15:26   ` Henning Hraban Ramm
2024-10-28 17:54     ` Wolfgang Schuster [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=ede1fab3-2140-bb39-2f8e-508cbc3eefb7@gmail.com \
    --to=wolfgang.schuster.lists@gmail.com \
    --cc=ntg-context@ntg.nl \
    --cc=texml@fiee.net \
    /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).