Guidance
指路人
g.yi.org
software / rapidq / Examples / Tools - IDE, Designer, Builder / FreeQ IDE src / tools / File2html.inc

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' RQB2HTML - Rapid-Q BASIC source code to HTML converter by William Yu
'
' Requires KEYWORD.LST, which should be included in your Rapid-Q distribution.
' You can modify this file to support other BASIC languages if you want
'
' this version is modified for  FreeQ IDEa

     SUB File2Html (inTxt AS STRING, outFile AS STRING, useEscapes AS INTEGER)
      DIM keyList AS QSTRINGLIST
      DIM i       AS LONG
      DIM j       AS LONG
      DIM quote   AS BYTE
      DIM ch      AS STRING * 1
      DIM token   AS STRING


      IF FILEEXISTS("keyword.lst") = 0 THEN
       SHOWMESSAGE "ERROR can't find file keyword.lst"
       EXIT SUB
      ELSE
       keyList.LoadFromFile("keyword.lst")
      END IF

      IF gFStream.OPEN(outFile, fmCreate) = 0 THEN
       SHOWMESSAGE "ERROR in creating file " + outFile
       EXIT SUB
      END IF

      Stat.Panel(5).CAPTION = "converting to html > " + outFile
      gFStream.writeLine("<html>")
      gFStream.writeLine("<head>")
      gFStream.writeLine("<title> RapidQ Code </title>")
      gFStream.writeLine("</head>")
      gFStream.writeLine("<body bgcolor="+Quot$+"FFFFFF"+Quot$+">")
      gFStream.writeLine("<pre>")


      tmpList.text = inTxt
      FOR i = 0 TO tmpList.itemCount-1
       quote = FALSE
       token = ""
       FOR j = 1 TO LEN(tmpList.item(i))
        ch = tmpList.item(i)[j]
        IF INSTR("+-=<>()\/^&*[]:;?, "+ Quot$ + TAB, ch) THEN
         IF ch = Quot$ THEN
          gFStream.write(ch)
          FOR j = j+1 TO LEN(tmpList.item(i))
           ch = tmpList.item(i)[j]
           IF useEscapes THEN
            IF ch = "\\" THEN
             token = token + ch
             j++
             ch = tmpList.item(i)[j]
             token = token + ch
            ELSEIF ch = Quot$ THEN
             EXIT FOR
            ELSE
             IF ch = "<" THEN
              token = token + "&lt;"
             ELSE
              token = token + ch
             END IF
            END IF
           ELSE
            IF ch = Quot$ THEN
             EXIT FOR
            ELSE
             IF ch = "<" THEN
              token = token + "&lt;"
             ELSE
              token = token + ch
             END IF
            END IF
           END IF
          NEXT
          gFStream.write("<font color="+Quot$+"990000"+Quot$+">"+token+"</font>")
         ELSEIF ch = sQuot THEN
          IF token <> "" THEN
           IF keyList.find(UCASE$(token)) <> -1 THEN
            gFStream.write("<font color="+Quot$+"0000AA"+Quot$+"><b>"+token+"</b></font>")
           ELSE
            gFStream.write(token)
           END IF
          END IF
          token = ""
          FOR j = j TO LEN(tmpList.item(i))
           ch = tmpList.item(i)[j]
           IF ch = "<" THEN
            token = token + "&lt;"
           ELSE
            token = token + ch
           END IF
          NEXT
          gFStream.write("<font color="+Quot$+"007700"+Quot$+"><i>"+token+"</i></font>")
          ch = ""
         ELSEIF token <> "" THEN
          IF keyList.find(UCASE$(token)) <> -1 THEN
           gFStream.write("<font color="+Quot$+"0000AA"+Quot$+"><b>"+token+"</b></font>")
          ELSE
           gFStream.write(token)
          END IF
         END IF

         IF ch = "<" THEN
          gFStream.write("&lt;")
         ELSEIF ch = "(" OR ch = ")" THEN
          gFStream.write("<b>"+ch+"</b>")
         ELSE
          gFStream.write(ch)
         END IF
         token = ""
        ELSE
         token = token + ch
        END IF
       NEXT
       IF token <> "" THEN
        IF keyList.find(UCASE$(token)) <> -1 THEN
         gFStream.write("<font color="+Quot$+"000099"+Quot$+"><b>"+token+"</b></font>")
        ELSE
         gFStream.write(token)
        END IF
       END IF
       gFStream.write(CRLF)
       $IFDEF WIN32
        LOCATE CSRLIN, 1
'         PRINT format$("%3d", i*100 \ (tmpList.itemCount-1)) + "% complete.    ";
       $ENDIF
      NEXT

      gFStream.writeLine("</pre>")
      gFStream.writeLine("</body>")
      gFStream.writeLine("</html>")
      gFStream.CLOSE
     END SUB
' File2Html ==== end

掌柜推荐
 
 
¥1,420.00 ·
 
 
¥950.00 ·
 
 
¥288.00 ·
 
 
¥738.00 ·
 
 
¥397.00 ·
 
 
¥750.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-12-07 21:18:03