'=========================================================================== ' Subject: .BAS TO HTML CONVERTER Date: 07-07-97 (12:29) ' Author: Edward Blake Code: QB, QBasic, PDS ' Origin: blakee@rcsn.nb.ca Packet: HTML.ABC '=========================================================================== ' Author: Edward Blake ' Email Address: blakee@rcsn.nb.ca ' Version: 1.0 ' Started Coding: March 4, 1997 ' Ended Coding: March 7, 1997 '---------------------------------------------------------------------- ' Description: ' Program that takes a BASIC file and make some kind of HTML file. ' It makes the source more readable with green comments (using the ) ' and procedure calls are linked to the procedures themselves ' You can use this program to show your BASIC source code on the Web. ' ' ' This is kinda the first version of this program so it is kinda buggy! ' ' Please give me credit (show my name someplace.. whatever) if you plan to ' use the source code of this program in another program. ' CONST TRUE = -1 CONST FALSE = NOT TRUE CONST implement = 1 ' Constant for knowing where this is running ' 0 = QBasic ' 1 = QuickBasic DIM SUBTable$(50) ' Table for recording 50 subs DIM SUBPtr AS INTEGER ' Points to the next empty entry in SUBTable$ DQ$ = CHR$(34) ' Double Quotes CR$ = CHR$(13) + CHR$(10) ' Cariage Return - Line Feed PRINT PRINT "BAS2HTML 1.0 - By Edward Blake" PRINT PRINT "BAS2HTML [BASFile.BAS]" PRINT "The Output HTML will be in BASFile.htm (same filename before '.')" PRINT "This will convert a BASIC file's comments into green comments and" PRINT "And the procedure calls will have a link to the procedure itself." PRINT "You can use this program to show your BASIC source code on the Web." PRINT IF implement = 1 THEN ' Using QuickBasic? IF COMMAND$ <> "" THEN File$ = COMMAND$ ELSE INPUT "Input BAS file: ", File$ END IF ELSE ' Using something else INPUT "Input BAS file: ", File$ END IF IF File$ = "" THEN PRINT "no file specified, aborting.." SYSTEM END IF IF INSTR(1, File$, ".") = 0 THEN OutFile$ = File$ + ".htm" File$ = File$ + ".bas" ELSE OutFile$ = LEFT$(File$, INSTR(1, File$, ".") - 1) + ".htm" END IF OPEN File$ FOR INPUT AS #1 PRINT "Now starting..." PRINT "Now doing first pass of " + File$ + " for some scanning." PRINT "Progress"; DO UNTIL EOF(1) LINE INPUT #1, Buf$ IF UCASE$(LEFT$(LTRIM$(Buf$), 4)) = "SUB " THEN Buf$ = LTRIM$(Buf$) IF INSTR(5, Buf$, " ") <> 0 THEN SUBTable$(SUBPtr) = MID$(Buf$, 5, INSTR(5, Buf$, " ") - 5) ELSEIF INSTR(5, Buf$, "(") <> 0 THEN SUBTable$(SUBPtr) = MID$(Buf$, 5, INSTR(5, Buf$, "(") - 5) ELSE SUBTable$(SUBPtr) = RIGHT$(Buf$, LEN(Buf$) - 4) END IF SUBPtr = SUBPtr + 1 END IF PRINT "."; LOOP CLOSE #1 PRINT "Now doing second pass of " + File$ + " scanning." PRINT "Now opening " + OutFile$ + " for outputting the information." PRINT "Progress"; OPEN File$ FOR INPUT AS #1 OPEN OutFile$ FOR OUTPUT AS #2 PRINT #2, "" + CR$ + "" + CR$ + "" + File$ + " - BASIC Code" + CR$ + "" + CR$ + "" PRINT #2, "" + CR$ + "

" + File$ + " - BASIC Code

This file was created by Edward Blake's BAS2HTML
"
DO UNTIL EOF(1)
        LINE INPUT #1, Buf$
        RBuf$ = Buf$
        IF SUBPtr <> 0 THEN
                FOR I = 0 TO SUBPtr - 1
                        IF INSTR(1, Buf$, SUBTable$(I)) <> 0 THEN
                                RBuf$ = ""
                                IF UCASE$(LEFT$(LTRIM$(Buf$), 4)) = "SUB " THEN
                                RBuf$ = RBuf$ + ""
                                END IF
                                RBuf$ = RBuf$ + LEFT$(Buf$, INSTR(1, Buf$, SUBTable$(I)) - 1)
                                RBuf$ = RBuf$ + ""
                                RBuf$ = RBuf$ + MID$(Buf$, INSTR(1, Buf$, SUBTable$(I)), LEN(SUBTable$(I)))
                                RBuf$ = RBuf$ + ""
                                RBuf$ = RBuf$ + RIGHT$(Buf$, LEN(Buf$) - (INSTR(1, Buf$, SUBTable$(I)) + LEN(SUBTable$(I)) - 1))
                        END IF
                        IF INSTR(1, RBuf$, "'") <> 0 THEN
                        RBuf$ = LEFT$(RBuf$, INSTR(1, RBuf$, "'") - 1) + "" + RIGHT$(RBuf$, LEN(RBuf$) - INSTR(1, RBuf$, "'") + 1) + ""
                        END IF

                NEXT I
        ELSE
                IF INSTR(1, RBuf$, "'") <> 0 THEN
                RBuf$ = LEFT$(RBuf$, INSTR(1, RBuf$, "'") - 1) + "" + RIGHT$(RBuf$, LEN(RBuf$) - INSTR(1, RBuf$, "'") + 1) + ""
                END IF
        END IF
        PRINT ".";
        PRINT #2, RBuf$
LOOP
PRINT #2, "
" + CR$ + "" + CR$ + "" CLOSE #1, #2