Rik Kabel
31. Januar 2018 um 03:10

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?


Natural tables collect the content of all cells to perform the width and height calculations
and you have to expand the content of the cells to get the current value of \getvariable.

\starttexdefinition unexpanded doTableRow #SET
    \bTR
      \expanded{\bTC\getvariable{#SET}{a}\eTC}
      \expanded{\bTC\getvariable{#SET}{b}\eTC}
    \eTR
\stoptexdefinition


BTW: You can use the \processcommacommand command when you save your lists in a macro (no need for \expandafter).

\defineexpandable\Sets{one,two}

\processcommacommand[\Sets]\doInlineTextExp


Wolfgang