Thomas A. Schmitz wrote:
I thought I had understood at least some aspects of macros, but it turns out I'm as lost as always. Here's my problem: I'm writing a module which will have a \setupcommand. The value is given in a [key=pair] list, so I thought I could use \getvariable. What I have is
\def\setupcommand{\setvariables[namespace]} % setting up the namespace \setvariables[namespace][key=value,otherkey=value] % initializing the keys
% And now I want to wrap my values up in a conditional statement: \doifelse{\getvariable{namespace}{key}}{value} {do something} {do something else}
When I put the \doifelse statement into my source files, the test works; the key is assigned the value that is in the setupcommand. But this doesn't work at runtime: either \getvariable{namespace}{key} always has the value I assign in the line \setvariables[namespace] [key=value,otherkey=value], or if I comment out that line, the variable is empty. I can see why this is the case: the setupcommand is read AFTER the module, so at runtime, the variable is not assigned yet. So my approach seems fundamentally flawed. What could I do instead?
I'm not sure what you mean but there is the following mechanism: \startsetups namespace:reset \doifelse{\getvariable{namespace}{key}}{value} {do something} {do something else} \stopsetups \startsetups namespace:set \doifelse{\getvariable{namespace}{key}}{value} {do something} {do something else} \stopsetups \setvariables[namespace][reset=namespace;reset,set=namespace:set] now, when you say: \setvariables[namespace][key=value] first the 'namespace:reset' setups will be executed, then the assignment, and afterwards the 'namespace:set' setups. So, you can have actions before and after assignments. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------