ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Rik Kabel <context@rik.users.panix.com>
To: ntg-context@ntg.nl
Subject: Re: Expansion help needed, getvariable and TABLE
Date: Tue, 30 Jan 2018 21:31:32 -0500	[thread overview]
Message-ID: <526487a7-15c4-6e7b-45b0-e06c10221e30@rik.users.panix.com> (raw)
In-Reply-To: <510aff38-9cc5-bebd-107d-a569695a4403@rik.users.panix.com>

On 2018-01-30 21:10, Rik Kabel wrote:
>
> Listers,
>
> I have a problem, and a question on ConTeXt programming efficiency.
>
> In the example below, I have a set of variables. When these are 
> reference directly via \getvariable, everything works as expected in 
> simple text and in TABLEs. When I \define a macro to the \getvariable, 
> that works in simple text, but only the value of the last iteration 
> appears in the TABLE. The macro definition is saved and when it is 
> used, that is the value that it has.
>
> So, how can I \define (or \def, ...) a macro to the expanded value to 
> avoid this? That is the problem.
>
> The question is, Is there is any advantage to be had in doing this? 
> Assume that the value is referenced many (tens of) times. There seems 
> to be an aesthetic value of factoring out the multiple identical 
> instances of the \getvariable syntax and assigning a more semantically 
> informative name, but beyond that, is there any other value?
>

Replying to my own query, I see that I just have to localize the 
definitions by grouping them, as

\starttexdefinition doTableRowExp #SET
    {\define\A{\getvariable{#SET}{a}}
     \define\B{\getvariable{#SET}{b}}
     \bTR
       \bTC\A\eTC
       \bTC\B\eTC
     \eTR}
\stoptexdefinition

Does it matter if I use {}, \bgroup\egroup, or some other mechanism?

My style question is still outstanding.

-- 
Rik
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2018-01-31  2:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-31  2:10 Rik Kabel
2018-01-31  2:31 ` Rik Kabel [this message]
2018-01-31  6:04 ` Wolfgang Schuster
2018-01-31 14:47   ` Rik Kabel
2018-01-31 14:54     ` Wolfgang Schuster
2018-01-31 15:40       ` Rik Kabel
2018-01-31 16:06         ` Hans Hagen

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=526487a7-15c4-6e7b-45b0-e06c10221e30@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).