chneves
12th January 2007, 22:13
Hi

I need make a "Macro Substitution" how below:


declaration:
(...)
extern domain tcpdno op01.o, op02.o, op03.o, (...), op40.o


#define OPNO(x) op##x##.o
(...)
for i = 1 to 40
aux.op = edit$(i, "Z9")
var.array(1, i) = edit$(OPNO(aux.op), "999999")
endfor



But generate a error, because it is pasting "aux.op" and do not "01", "02"... (Value of aux.op)
Then it is staying "opaux.op.o", and do not "op01.o", "op02.o" how would have to be.

I need help, please...

tks

Hitesh Shah
13th January 2007, 16:45
U need to use dynamic expression using expr.compile like


long op.expr
for i = 1 to 40
op.expr = expr.compile("op" & edit$(i, "Z9") & "o")
var.array(1, i) = edit$(d.expr(op.expr), "999999")
expr.free(op.expr)
endfor

chneves
15th January 2007, 03:20
Hi Hitesh Shah

Very very thanks for your reply!!!
I did not know expr.compile, and I also see in link:

http://www.baanboard.com/baanboard/showthread.php?t=25169

My code stay how below:
for aux.i = 1 to 40
aux.expr = sprintf$("op%s.o", edit$(aux.i, "99"))
op.expr = expr.compile(aux.expr)
matrix.op.dt(1,aux.i) = s.expr$(op.expr)
aux.op = val(s.expr$(op.expr))
expr.free(op.expr)
endfor


Very Tks :D :D