Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Nested items in textmerge
Message
From
08/10/2009 23:19:14
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01428366
Message ID:
01428396
Views:
47
>Not sure I understand the usefullness of the recursive parameter in this function, attempting to next an substitution item inside another doesn't work:
>
>
>* spaces added after the < so the UT will post the message
>one = "test"
>two = "123"
>lcfield = "start< < callit( '< < one>>', '< < two>>' )>>end"
>lcx = textmerge( lcfield, .t. )  && error 36 barfs up
>
>function callit( lc1, lc2 )
>return lc1 + lc2
>
>
>If I use two separate delimiters sets and two calls it works:
>
>
>lcfield = "< < callit( '{{one}}', '{{two}}' )>>end"
>lcx = textmerge( lcfield, .t., "{{", "}}" )
>lcy = textmerge( lcx )
>
>
>Is there any way to do this with one call to textmerge()?

Not this one, because you have nested delimiters in the first pass. Fox will find
<< callit( '<< one>>
as the first delimited string, will strip the delimiters and try to evaluate what's inside - error 36. "Nested" works as Sergey described, merge and see if there is something to merge again. So if one of the variables contains delimiters, this would work:
one = "test"
two = "123"
lcExpr= [callit( '<< one>>', '<< two>>' )]
lcfield = "start<<lcExpr>>end"
lcx = textmerge( lcfield, .t. )
This would do it in two passes, but it should do it. And at every pass it would resolve one level of merge.

p.s. within pre tags, UT doesn't interpret HTML, so spaced less-thans aren't necessary.

update: now that I've tried it, I'm not getting function call resolved - I get startcallit('test', '123')end, and that's because Fox evaluates it from outside in, so it first resolves it to startcallit('< < one>>', '< < two>>')end, and then substitutes values for the inner variables. The only way I got this to work was
one = "test"
two = "123"
lcExpr= TEXTMERGE([callit('<< one>>', '<<two>>')])
lcExpr2=TEXTMERGE("<<EVALUATE(lcExpr)>>")
lcfield = "start<<lcExpr2>>end"
lcx = textmerge( lcfield)
I guess you could put evaluate() straight into the last merge, so two may suffice. I don't see a way you can do this with just one merge.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform