~Vamsi
4th February 2002, 21:04
This works:
#define STR(...) """" & ... & """"
temp.string = "abc|defg"
pipe.markers = "...|...."
exprstr = STR(temp.string) & " in " & STR(pipe.markers)
expr_id = expr.compile(exprstr)
if l.expr(expr_id) then
foo.bar()
endif

This requires me to use expr.compile every time a new expression needs to be evaluated. Instead I would like to compile the expression once and just assign values to temp.string and pipe.markers and call l.expr on the fly.

francishsu
5th February 2002, 22:32
According to the Baan help (have not tried this out myself), l.expr can take an optional argument that gets put into "$$", if it exists in your regular expression. So you should be able to do the following:


#define STR(...) """" & ... & """"
temp.string = ""abc|defg"
pipe.markers = "...|...."
|exprstr = STR(temp.string) & " in " & STR(pipe.markers)
exprstr = "$$ in " & STR(pipe.markers)
expr_id = expr.compile(exprstr)
|if l.expr(expr_id) then
if l.expr(expr_id, temp.string) then
foo.bar()
endif


You can then set temp.string to other values and call l.expr without having to do another expr.compile

francishsu
5th February 2002, 22:37
Actually it looks like you can just put the variable names in the expression itself?

e.g. expr.compile("temp.string in pipe.markers")

francishsu
6th February 2002, 00:09
I did some testing. It appears that "IN" restricts you to using a constant for the right half.
e.g.
x IN "abc" is permitted but
"abc" IN x is not

Therefore, I don't believe it will be possible to handle variable pipe.markers with a single expr.compile, but you can handle variable temp.string with a single expr.compile.

~Vamsi
6th February 2002, 23:47
Thank you. Thank you!

I monitor the board using "View new posts" and somehow your posts went by me. I tried your method and it works great.

And did I thank you :)!