QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

Re: HTML Challenge

January 5 2010 at 8:19 PM
  (Login The-Universe)
Admin


Response to HTML Challenge

 

Not to be a downer, but that is as simple as using Line Input to read the text and output to write the HTML page. The only thing you need to add are HTML hyperlink tags to any word that starts with http.

I mean you could add <html><body> and end it with </body></html> but you don't even have to do that...

Save as xyz.txt
--------------------------
This is a text file that will be converted into an HTML file with
links to sites like http://www.qb64.net and http://google.com. It
won't do indentation, email hyperlinks, or much of anything else
but at least I finished it during a commercial break for NCIS.
--------------------------

CLS
OPEN "xyz.txt" FOR INPUT AS #1
OPEN "xyz.htm" FOR OUTPUT AS #2
DO UNTIL EOF(1)
LINE INPUT #1, a$
IF RIGHT$(a$, 1) <> " " THEN a$ = a$ + " "
DO UNTIL INSTR(flag + 1, LCASE$(a$), "http") = 0
x = INSTR(flag + 1, LCASE$(a$), "http")
y = LEN(MID$(a$, INSTR(flag + 1, a$, "http"), INSTR(x, LCASE$(a$), " ") - x))
a$ = MID$(a$, 1, x - 1) + "<a href=" + CHR$(34) + MID$(a$, INSTR(flag + 1, a$, "http"), INSTR(x, LCASE$(a$), " ") - x) + CHR$(34) + ">" + MID$(a$, INSTR(flag + 1, a$, "http"), INSTR(x, LCASE$(a$), " ") - x) + "</a>" + MID$(a$, INSTR(x, LCASE$(a$), " "))
flag = x + 12 + y
LOOP
PRINT #2, a$ + "<br />"
LOOP
CLOSE
SHELL "cmd /c start xyz.htm"

----------------------------------

Pete

PS: The code works, but I'm having a little trouble getting it to post correctly.


 
 Respond to this message   
Responses

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement