This is just a fast little program I wrote in Qbasic for my own uses. But then I thought there must be other noders that do the same thing I do. I don't know about you but when I am writing E-mails I always find myself wanting to put links to everything in them. So I decided to write a program that converts Everythingeses to HTML (ie [ ] to links). It is in Qbasic, I think most win95 computers come with Qbasic. To run the program, just copy it to a text file, then open that text file in Qbasic. Don't copy it to Qbasic because it won't copy properly. You can post Patches or /msg me if you find any problems.

DECLARE FUNCTION everything2html$ (words$)
DECLARE FUNCTION makelink$ (words$)
CLS
rFileName$ = "Input File goes here"
wFileName$ = "Output File goes here"

readme = FREEFILE
OPEN rFileName$ FOR INPUT AS readme
writeme = FREEFILE
OPEN wFileName$ FOR OUTPUT AS writeme
DO
   LINE INPUT #readme, In$
   PRINT #writeme, everything2html$(In$)
LOOP UNTIL EOF(readme)
CLOSE readme
CLOSE writeme
SYSTEM

FUNCTION everything2html$ (words$)
   link = 0
   link$ = ""
   out$ = ""
   FOR a = 1 TO LEN(words$)
      IF MID$(words$, a, 1) = "[" THEN
         link = 1
      ELSEIF MID$(words$, a, 1) = "]" THEN
         link = 0
         out$ = out$ + makelink$(link$)
         link$ = ""
      ELSEIF link = 1 THEN
         link$ = link$ + MID$(words$, a, 1)
      ELSE
         out$ = out$ + MID$(words$, a, 1)
      END IF
   NEXT
   everything2html$ = out$
END FUNCTION

FUNCTION makelink$ (words$)
   link$ = ""
   out$ = ""
   FOR a = 1 TO LEN(words$)
      IF MID$(words$, a, 1) = "|" THEN
         out$ = "<A HREF=" + CHR$(34) + "http://everything2.com/index.pl?node=" + link$ + CHR$(34) + " >"
         out$ = out$ + RIGHT$(words$, LEN(words$) - a) + "</A>"
         EXIT FOR
      ELSE
         link$ = link$ + MID$(words$, a, 1)
      END IF
   NEXT
   IF out$ = "" THEN
      out$ = "<A HREF=" + CHR$(34) + "http://everything2.com/index.pl?node=" + link$ + CHR$(34) + " >"
      out$ = out$ + link$ + "</A>"
   END IF
   makelink$ = out$
END FUNCTION

The following QuickBASIC program is based on mE123's QBasic program above, but it reads the command line for the input file name, then writes the output file to C:\WINDOWS\TEMP\PREVIEW.HTM. After doing so, it automatically executes a new window of EXPLORER.EXE to view the document. It's not quite Netscape-friendly, but this can easily be changed by putting in the full path to NETSCAPE.EXE or whatever the main executable is in place of the word "EXPLORER" at the "SHELL" command.

The main function of this program is to allow one to "preview" a node without actually submitting it. If on-line, you can follow the links and see if they actually go anywhere before submitting. It's not a perfect preview by any means, but it will help one find misplaced hard link brackets, and it provides a general run-down of how the write-up will appear. Note that there are some tags that aren't supported by E2, so make sure the tags you're using are in E2 HTML Tags. Also note that while it is odd to use an ancient DOS programming language to call a windows application, it won't cause your computer to explode or create any sort of quantum-space-time-collapse effect.


The bold is my added/revised code, the rest is mE123's...

DECLARE FUNCTION everything2html$ (words$)
DECLARE FUNCTION makelink$ (words$)
ON ERROR GOTO death
CLS
rFileName$ = COMMAND$
wFileName$ = "C:\windows\temp\preview.htm"
readme = FREEFILE
OPEN rFileName$ FOR INPUT AS readme
writeme = FREEFILE
OPEN wFileName$ FOR OUTPUT AS writeme
DO
   LINE INPUT #readme, In$
   PRINT #writeme, everything2html$(In$)
LOOP UNTIL EOF(readme)
CLOSE readme
CLOSE writeme
SHELL "Explorer " + wFileName$
SYSTEM
death:
PRINT "Syntax: E2P <inputfile>"
END

FUNCTION everything2html$ (words$)
  link = 0
  link$ = ""
  out$ = ""
   FOR a = 1 TO LEN(words$)
      IF MID$(words$, a, 1) = "[" THEN
  link = 1
      ELSEIF MID$(words$, a, 1) = "]" THEN
  link = 0
  out$ = out$ + makelink$(link$)
  link$ = ""
      ELSEIF link = 1 THEN
  link$ = link$ + MID$(words$, a, 1)
      ELSE
  out$ = out$ + MID$(words$, a, 1)
      END IF
   NEXT
  everything2html$ = out$
END FUNCTION

FUNCTION makelink$ (words$)
  link$ = ""
  out$ = ""
   FOR a = 1 TO LEN(words$)
      IF MID$(words$, a, 1) = "|" THEN
  out$ = "<A HREF=" + CHR$(34) + "http://everything2.com/index.pl?node=" + link$ + CHR$(34) + " >"
  out$ = out$ + RIGHT$(words$, LEN(words$) - a) + "</A>"
         EXIT FOR
      ELSE
  link$ = link$ + MID$(words$, a, 1)
      END IF
   NEXT
   IF out$ = "" THEN
  out$ = "<A HREF=" + CHR$(34) + "http://everything2.com/index.pl?node=" + link$ + CHR$(34) + " >"
  out$ = out$ + link$ + "</A>"
   END IF
  makelink$ = out$
END FUNCTION

Log in or register to write something here or to contact authors.