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?
% macros=mkvi engine=luajittex \setvariables [one] [a=1a,b=1b] \setvariables [two] [a=2a,b=2b] \define \Sets {one,two} \starttexdefinition unexpanded doInlineText #SET Direct: \getvariable{#SET}{a} \getvariable{#SET}{b}\par \stoptexdefinition \starttexdefinition unexpanded doTableRow #SET \bTR \bTC\getvariable{#SET}{a}\eTC \bTC\getvariable{#SET}{b}\eTC \eTR \stoptexdefinition \starttexdefinition doInlineTextExp #SET \define\A{\getvariable{#SET}{a}} \define\B{\getvariable{#SET}{b}} Factored: \A\ \B\par \stoptexdefinition \starttexdefinition doTableRowExp #SET \define\A{\getvariable{#SET}{a}} \define\B{\getvariable{#SET}{b}} \bTR \bTC\A\eTC \bTC\B\eTC \eTR \stoptexdefinition \starttext \starttext \expandafter\processcommalist\expandafter[\Sets]\doInlineText \bTABLE[frame=off] \bTABLEhead \bTR[nc=2] \bTH Direct\eTH \eTR \eTABLEhead \bTABLEbody \expandafter\processcommalist\expandafter[\Sets]\doTableRow \eTABLEbody \eTABLE \expandafter\processcommalist\expandafter[\Sets]\doInlineTextExp \bTABLE[frame=off] \bTABLEhead \bTR[nc=2] \bTH Factored\eTH \eTR \eTABLEhead \bTABLEbody \expandafter\processcommalist\expandafter[\Sets]\doTableRowExp \eTABLEbody \eTABLE \stoptext -- 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 ___________________________________________________________________________________