>
IF lnHandle > 0
> _TEXT = lnHandle
> TEXT TO _TEXT NOSHOW ADDITIVE TEXTMERGE
> Message
> ENDTEXT
> =FCLOSE(lnHandle)
>ENDIF
You should know that _text is a system variable in Fox (since 2.0 or maybe 1.0?). It holds a handle to the textmerge output file. So... from VFP help on text...endtext:
TO VarName
Specifies the memory variable name to use for passing the contents of the TEXT...ENDTEXT. This variable can already exist.
If the variable has not yet been declared, Visual FoxPro automatically creates it as a private variable. The TO clause operates regardless of how SET TEXTMERGE is set. If SET TEXTMERGE is set to a file, and the TO statement is included, Visual FoxPro outputs both the file and variable.
So your _text variable would have to become a string here, while still trying to keep the handle number. I'm not sure this would work.
In the olden days, the technique of the assignment in the other direction used to work, like this:
IF lnHandle > 0
_TEXT = lnHandle
TEXT NOSHOW TEXTMERGE
Message
ENDTEXT
=FCLOSE(lnHandle)
ENDIF
I.e. it was assumed that any textmerge command was going to the file whose handle was in _text. That way you could write textmerge into dozen files, all open at the same time, by assigning _text=handle of the one you want at the moment.
But this technique was clumsy at best, and I think I haven't used it for at least 15 years. What Sergey said is much better and easier to maintain.