BackStyle

Text ... EndText

This delimiter pair lets you specify a block of text to be sent somewhere (where depends on other settings) without having to put quotes around it or use a printing command like ?. It's most useful with textmerge. VFP 7 enhanced this command significantly so it can be used to perform textmerge without the need for the SET TEXTMERGE command.

Usage

TEXT [ TO VarName [ ADDITIVE ] [ TEXTMERGE ] [ NOSHOW ] ] OutputText ENDTEXT
When FoxPro hits a TEXT block, it sends the enclosed text either to the current output location (usually the active window) and/or to the specified variable. The NOSHOW clause, added in VFP 7, suppresses output to the current output location. The TEXTMERGE clause, also added in VFP 7, indicates that textmerge should be performed on the text block; that is, that items enclosed in the current textmerge delimiters ("<<" and ">>", by default) should be evaluated before being output.

There are several different ways to indicate where the text is stored. The easiest is to include the optional TO clause, which sends output to the specified variable. You can get the same effect by surrounding the TEXT block with the appropriate SET TEXTMERGE commands, and specifying a variable for the destination there. Note that you can't use SET TEXTMERGE TO MEMVAR and TEXT TO at the same time: That generates a "Textmerge is recursive" error.

An alternative approach, and the most useful prior to VFP 7, is to use SET TEXTMERGE with a file. This sends the text to the current textmerge output file and indicates that any items enclosed in the textmerge delimiters should be evaluated before being output.

Text can also be redirected with SET PRINT or by assigning a file handle to the _TEXT system variable. However, in this case, expressions in textmerge delimiters are not evaluated; they're simply copied.

We've also been known to use TEXT to surround long, explanatory comment blocks, especially in methods whose sole purpose is documentation. Be aware that IntelliSense doesn't realize you're inside a TEXT block, so be prepared to ignore its prompts, or even get rid of some of the "help" it offers. If you're working on a long enough TEXT block, it may even be worth turning IntelliSense off temporarily (through the IntelliSense Manager).

Example

* Here's the old way: SET TEXTMERGE TO Text.TXT  SET TEXTMERGE ON NOSHOW TEXT This text ends up in the output file. Any variables or functions enclosed in the delimiters will be evaluated. For example, today is <<DATE()>>. ENDTEXT SET TEXTMERGE OFF SET TEXTMERGE TO   * Here's the new way: LOCAL cOutput TEXT TO cOutput NOSHOW TEXTMERGE This text ends up in the cOutput variable. Any variables or functions enclosed in the delimiters will be evaluated. For example, today is <<DATE()>>. ENDTEXT

See Also

Set Print, Set TextMerge, _Text, TextMerge()


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net