Hi,

What's the problem (tested with VFP 8 + 9) with following textmerge?

----8<----
#DEFINE myConst "myText"

TEXT TO lcStmt TEXTMERGE NOSHOW
select * from myTable where field = "<<myConst>>"
ENDTEXT
---->8----



Ok, this would be a workaround, but it's not that nice :(

----8<----
#DEFINE myConst "myText"

TEXT TO lcStmt TEXTMERGE NOSHOW
select * from myTable where field = <<'"' + myConst + "'">>
ENDTEXT
---->8----

Thanks
Marco

Re: TEXTMERGE problem by Bernhard

Bernhard
Tue Jun 28 09:29:32 CDT 2005

Hi Marco

> What's the problem (tested with VFP 8 + 9) with following textmerge?
>
> ----8<----
> #DEFINE myConst "myText"
>
> TEXT TO lcStmt TEXTMERGE NOSHOW
> select * from myTable where field = "<<myConst>>"
> ENDTEXT
> ---->8----
I think, it is because the evaluation of everything between TEXT and ENDTEXT is
defered until runtime. Since all #DEFINEd constants are evaluated only during
compiletime, they are not available for the evalutation at runtime.

Regards
Bernhard Sander

Re: TEXTMERGE problem by Marco

Marco
Tue Jun 28 09:50:13 CDT 2005

Hi Bernhard,

>> What's the problem (tested with VFP 8 + 9) with following textmerge?
>>
>> ----8<----
>> #DEFINE myConst "myText"
>>
>> TEXT TO lcStmt TEXTMERGE NOSHOW
>> select * from myTable where field = "<<myConst>>"
>> ENDTEXT
>> ---->8----
> I think, it is because the evaluation of everything between TEXT and
> ENDTEXT is defered until runtime. Since all #DEFINEd constants are
> evaluated only during compiletime, they are not available for the
> evalutation at runtime.

Ok, but that should not be a problem. The #DEFINE should replace the myConst
with "myText" and that should run fine.


Here are some shorter examples.


1. doesn't work

---8<----
#DEFINE myConst "myText"

TEXT TO lcStmt TEXTMERGE NOSHOW
"<<myText>>
ENDTEXT
---->8----



2. doesn't work
---8<----
#DEFINE myConst "myText"

TEXT TO lcStmt TEXTMERGE NOSHOW
'<<myText>>
ENDTEXT
---->8----



3. works
---8<----
#DEFINE myConst "myText"

TEXT TO lcStmt TEXTMERGE NOSHOW
/<<myText>>
ENDTEXT
---->8----

bye
Marco



Re: TEXTMERGE problem by Olaf

Olaf
Tue Jun 28 14:44:27 CDT 2005

> 3. works
> ---8<----
> #DEFINE myConst "myText"
>
> TEXT TO lcStmt TEXTMERGE NOSHOW
> /<<myConst>>
> ENDTEXT
> ---->8----
By accident you put myText instead of myConst
between TEXT ... ENDTEXT. But besides that,
you're right the above works, so why not the others?

Hmm, nevertheless I'd say "why bother?",
Use this workaraound and load the constant
into a variable:

#DEFINE myConst "myText"
LOCAL lcConst
lcConst = myConst
TEXT TO lcStmt TEXTMERGE NOSHOW
"<<lcConst>>
ENDTEXT

That works in any case, whatever character you put before <<lcConst>>.

Bye, Olaf.



Re: TEXTMERGE problem by Marco

Marco
Tue Jun 28 17:59:48 CDT 2005

Hi Olaf,

>> 3. works
>> ---8<----
>> #DEFINE myConst "myText"
>>
>> TEXT TO lcStmt TEXTMERGE NOSHOW
>> /<<myConst>>
>> ENDTEXT
>> ---->8----
> By accident you put myText instead of myConst
> between TEXT ... ENDTEXT.

Oh yes, sorry. Copy & paste error ;=)



> But besides that,
> you're right the above works, so why not the others?

That's a good question. Maybe it's a bug in VFP? Or I don't understand the
TEXTMERGE <-> #DEFINE mechanism right?



> Hmm, nevertheless I'd say "why bother?",

Because, I wasted some time to find the problem!


> Use this workaraound and load the constant
> into a variable:
>
> #DEFINE myConst "myText"
> LOCAL lcConst
> lcConst = myConst
> TEXT TO lcStmt TEXTMERGE NOSHOW
> "<<lcConst>>
> ENDTEXT
>
> That works in any case, whatever character you put before <<lcConst>>.

Yes you are right, no problems with variables. I'm going to send a bug
report to Microsoft.

Thanks
Marco