Advertisement
6_2008-2009 Files/ File Controls/ Input/ Output #201622

Convert Text Document to HTML

This routine will allow you to convert any text document into an HTML document. This is a basic function that simply puts the template HTML tags into place and then adds line breaks after each line of the text file is read in. This would be handy function for converting large numbers of documents to web-format. This code would be used as following: Call FileToHTML("c:\autoexec.bat", "c:\test.html", "Auto Execute File", "maroon", "white")

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Public Sub FileToHTML(InputFile As String, OutputFile As String, title As String, bgcolor As String, textcolor As String)
  newline$ = Chr$(13) + Chr$(10)
  Open InputFile For Input As #1
  Open OutputFile For Output As #2
  
  If title = "" Then title = "No Document Title"
  If bgcolor = "" Then bgcolor = "white"
  If textcolor = "" Then textcolor = "black"
  
  Print #2, "<HTML>" + newline$
  Print #2, "<HEAD>" + newline$
  Print #2, "<TITLE>" + title + "</TITLE>" + newline$
  Print #2, "</HEAD>" + newline$
  Print #2, "<BODY bgcolor=" + bgcolor + " text=" + textcolor + ">" + newline$
  
  Do Until EOF(1)
    Line Input #1, myLine$
    Print #2, myLine$ + "<BR>"
  Loop
  
  Print #2, newline$
  Print #2, "</BODY>" + newline$
  Print #2, "</HTML>"
  Close #1
  Close #2
End Sub
Original Comments (3)
Recovered from Wayback Machine