Home About us Development Training Support |
HTML from FoxProHTML is just text and FoxPro has always been very good at manipulating text . Generating the HTML on your own PC gives you a static document on the web but that's sometimes all that the user needs. There are four easy ways of generating HTML from FoxPro:
Web Page WizardThis is more useful than most wizards and creates a table of data on a web page from a VFP table or cursor. The wizard generates an HTML file but can also generate a prg file to to recreate that web page. This generated program uses GenHTML and creates and uses a new entry in the GenHTML table. GenHTMLThe 'Save as HTML' option on the File menu calls the generator program specified by system variable _GENHTML. This is usually GenHTML.Prg but you can write your own utility if oyou want to improve it. GenHTML.Prg can be added to your project and distributed in an executable. Simple syntax is:
DO GenHTML With
lcHTMLFileName, lcTableName
You can extend the power of GenHTML by referring to two FoxPro Foundation Classes and a table of styles:
These too can be distributed in your application. TextMergeTextMerge is a tool that dates from FoxPro version 2.00 where we used it to create reports. TextMerge produces a pure ASCII output to a text file and the only way to get special effects in these reports was to embed printer control codes in the text. The Report Writer made life so much easier that TextMerge was little used. The output from TextMerge can be a mixture of text literals, the contents of fields or memory variables, or the result of VFP functions and TextMerge is now being used as a powerful tool for generating a web page from FoxPro data. More details on TextMerge here. StrToFileStrToFile is a new function introduced with VFP 5. It takes a string variable and writes it into a text file. You have the option of creating a new file, overwriting an existing file, or adding text to the end of an existing file. StrToFile returns the number of bytes written so you can check this value to ensure that your file has actually been created. The VFP 7 version of StrToFile (and its partner FileToStr) opens the file in Shared mode to reduce the risk of conflict
USE
Customer
*-- Start the string with a heading for the page lcHTML = '<h1>Customer List</h1>' *-- Now append 'Company' and the company name for each record SCAN    lcHTML = lcHTML + '<br>Company '    lcHTML = lcHTML + ALLTRIM (Company) ENDSCAN *-- And send it to a file =StrToFile (lcHTML, 'Customer.htm') FoxPro EditorDon't forget that FoxPro has a good text editor built in - much better than Notepad as a basic tool for writing HTML. Think of all these advantages:
|
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...
|