Home About us Development Training Support |
FoxPro TextMergeYou can use the Copy To command to create a simple text file from a table with various forms of delimiter between fields. The TextMerge commands let you create a more complex text file. The contents can be a mixture of plain text, fields and variables, and FoxPro functions. The commands are: Set Textmerge OnTell Fox to evaluate anything it sees between << and >>. These delimiters can be changed with the Set Delimiters To command. Set Textmerge To <filename> NoshowDirect the output to a file. The file will be created if it does not already exist. If the file does exist and Safety is On then you will be asked whether you want to overwrite it. The Noshow clause suppresses output to the screen. \xyzSend the characters 'xyz' to the file preceded by a CR LF combination. There is no need for quotes around the characters. If you put quotes around the characters then the quotes will be output as well. \\xyzSend the characters 'xyz' to the file on the current line. <<foxpro expression>>Evaluate the FoxPro expression. The expression can be the name of a field or memory variable or a FoxPro function. The example below shows how you can mix <<foxpro expression>> with plain text on the same line. Set TextMerge ToClose the output file. Set Textmerge OffStop evaluating expressions within << and >>. Text Merge ExampleThis example produces an HTML page holding a simple list of customers:
Use Customer
*-- Start the merge process *-- Use the noshow option so that no output *-- shows on screen Set Textmerge On Set Textmerge To customer.htm noshow *-- Just a minimal HTML document \<html> \<head> \<title>HTML from FoxPro</title> \</head> *-- Now for the body \<body> *-- Start with a level 1 heading and a line \<h1>Customer List</h1> \<hr /> *-- Output one line for each record in the table Scan    \Company name is <<Upper(Company)>>    \<br /> Endscan *-- Closing tags for the html page \</body> \</html> *-- Close the text file and stop merging Set Textmerge To Set Textmerge Off Use In Customer This short program will produce a text file named 'customer.htm' which looks like this in a browser:
This is a very simple page and the mixture of TextMerge and HTML can be confusing to write because both use the < and > symbols. It is however a very powerful and flexible technique which lets you build a page which will display a mixture of text and data. Visual FoxPro offers other ways of generating HTML. These are described on the HTML from FoxPro page. GotchaThere are two things to watch out for when using text merge and a third when using it to produce HTML:
|
Hints & tips
The textbox class in Visual FoxPro 9 has a new Autocomplete
property which shows the user the previous values that have
been entered in that textbox.
More...
|