MergeText is a template expansion method that can be used to 'merge' text into a document. The most common use you may be familiar with is for Web scripting where Active Server Style tags can be used to embed FoxPro code and expressions into an output stream.

Template expansion evaluates a page top to bottom. It does not 'run' the page. Rather each markup tag is evaluated or executed and then embedded into the output stream.

MergeText is fairly efficient especially if you keep to expressions and values rather than code blocks.

Merge Example

Hello World from <%= Version() %>.

The current time is: <%= time() %>.

If a table is open or a variable is marked as PRIVATE you can access
those values directly:

<%= myopenalias.field %>
<%= pcPrivateVar %>

The same goes for object references:

You can also embed UDF functions and object references (objects must be PRIVATE):

<%= MyUDFFunction %>
<%= poObject.DoSomething() %>

You can also embed full code blocks:

Here's a customer list:
pcOutput = ""
   pcOutput = pcOutput + TQuery.Company + "<br>"

RETURN pcOutput

Remember that you can change the merge parameters. This feature is by no means limited to HTML files. For example, the Web Connection Management Console uses this method to create new template driven programs based on choices made in the various Wizards. Check out the \templates directory and search for the tags for examples on how this works.

o.MergeText(tcString,tcDelimiter, tcDelimiter2, llNoASPSyntax)


String that contains the text to be merged

Optional - Starting tag delimiter

Optional - Ending Delimiter

Optional - Determines whether tags can represent eval and code blocks both by allowing an extra = sign with the delimiter. For example, ASP sytnax is: but by allowing the = operator like output can be directly sent into the document output. When this flag is .T. the equal sign is used to mean to embed the result text into the output.


This method performs template expansion using embedded FoxPro expressions and codeblocks. By default this method uses Active Server Style template tags ( and ).

See also:

Class wwEval

© West Wind Technologies, 1996-2018 • Updated: 01/09/16
Comment or report problem with topic