Macro-processor conditionals with loops

I’m trying to simulate a multi-sector model with search frictions and running into problems with the macro preprocessor when I try to create an integer value for a conditional test using loop indices. Code like this:

@#for l in 0:JJ @#for j in 1:JJ @#if (@{l} == @{j} || @{l}==0) Equation @#else Equation @#endif @#endfor @#endfor

Gives me the error

[quote]ERROR in macro-processor: occbc.mod:66.9: Macro lexer error: ‘@’
[/quote]

Should this operation be kosher, or does it make sense that I’d have trouble?
In the attached code, the problem first occurs on line 66, though I use a similar test elsewhere and get the same error.

Thanks very much,
David
occbc.mod (3.09 KB)

Once

is encountered, the macroprocessor interprets/expands everything else on that line. So, since l and j are macro variables, you do not need to dereference them with the

; you would only do this when you are NOT on a line that’s already being interpreted by the macroprocessor. Thus, the correction to the above buggy line is:

For more details, see the macroprocessor.pdf file in the doc directory of your Dynare distribution.