Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Praveen KumarRank #4 · 79.9K reputationPosted Jun 2, 2025, 5:22 AM EDT
To generate an HTML page from Visual FoxPro 9 (VFP9), you can follow a simple approach using its built-in file and string-handling capabilities.
Method: Write HTML to File Using STRTOFILE()
Here’s a basic example of how to generate and save an HTML file from VFP9:
Sample VFP Code to Generate an HTML Page
* Define your HTML content lcHTML = ; "" + CHR(13) + ; "" + CHR(13) + ; "My VFP HTML Page" + CHR(13) + ; "" + CHR(13) + ; "Hello from Visual FoxPro 9!" + CHR(13) + ; "This HTML page was generated using VFP9. " + CHR(13) + ; "" + CHR(13) + ; "" * Set output file path lcFile = "my_page.html" * Write to file =STRTOFILE(lcHTML, lcFile) * Optional: Open it in browser RUN /N my_page.htmlExplanation
STRTOFILE() writes the HTML string to a file.
CHR(13) or CHR(13)+CHR(10) adds line breaks.
RUN /N opens the HTML in the default web browser (Windows only).
Dynamic HTML from VFP Table
You can generate an HTML table from VFP data like this:
USE customers lcHTML = ; "Customer List" + CHR(13) + ; "IDNameCity" SCAN lcHTML = lcHTML + ; "" + TRANSFORM(customer_id) + "" + ; "" + ALLTRIM(name) + "" + ; "" + ALLTRIM(city) + "" + CHR(13) ENDSCAN lcHTML = lcHTML + "" =STRTOFILE(lcHTML, "customers.html") RUN /N customers.htmlTip
You can also apply CSS styles, include JavaScript, or generate complex reports using this method — just treat it like you’re building a string template.