Results 1 to 2 of 2

Thread: [Release v2] Visual Basic Colour coding

Threaded View

  1. #1
    Senior Member John is on a distinguished road
    Join Date
    Apr 2000
    Location
    Hastings, UK
    Age
    26
    Posts
    4,063

    [Release v2] Visual Basic Colour coding

    My first hack for vB

    In functions.php, add this in at line 425, just after several lines of code about $replacearray

    PHP Code:
    // START VISUAL BASIC PARSING HACK
    if (!function_exists("visbasparse")) {
      global 
    $kw;
      if (
    $incp) {
        include(
    "./visbas.php");
      } else {
        include(
    "./admin/visbas.php");
      }
    }
    $searcharray[] = "/(\[)(vbcode)(])(\r\n)*(.*)(\[\/vbcode\])/esiU";
    $replacearray[] = "visbasparse('\\5')";
    // END VISUAL BASIC PARSING HACK 
    And then upload visbas.php to the admin directory:
    PHP Code:
    <?php
    error_reporting
    (7);
    $kw=array("#Const","#If","Abs","Add","Alias","And","Any","AppActivate","Array","As","Asc","Atn","Base","Beep",
    "Boolean","Byte","ByVal","CBool","CByte","CCur","CDBl","CDate","CDec","CInt","CLng","CSng","CStr","CVErr","CVar",
    "Call","Case","ChDir","ChDrive","Chr","Clear","Close","Collection","Command","Compare","Const","Cos","CreateObject",
    "CurDir","Currency","DDB","Date","DateAdd","DateDiff","DatePart","DateSerial","DateValue","Day","Debug","Declare",
    "DefBool","DefByte","DefCur","DefDate","DefDbl","DefDec","DefInt","DefLng","DefObj","DefSng","DefStr","DefVar",
    "DeleteSetting","Dim","Dir","Do","DoEvents","Double","EOF","Each","Else","ElseIf","End","Endif","Environ","Eqv",
    "Erase","Err","Error","Exit","Exp","Explicit","FV","FileAttr","FileCopy","FileDateTime","FileLen","Filelen","Fix",
    "For","Format","Function","Get","GetAllSettings","GetAttr","GetObject","GetSetting","Global","GoSub","GoTo","Hex",
    "Hour","IIR","IPmt","If","Imp","In","InStr","Input #","Int","Integer","Is","IsArray","IsDate","IsEmpty","IsError",
    "IsMissing","IsNull","IsNumeric","IsObject","Item","Kill","LBound","LCase","LOF","LSet","LTrim","Left","Len","Let",
    "Lib","Like","Line Input #","Loc","Lock","Log","Long","Loop","MIRR","Me","Mid","Minute","MkDir","Mod","Module",
    "Month","MsgBox","NPV","NPer","Name","New","Next","Not","Now","Object","Oct","On","Open","Option","Or","PPmt","PV",
    "Pmt","Print","Print #","Private","Property","Public","Put","QBColor","RGB","RSet","RTrim","Raise","Randomize",
    "Rate","ReDim","Remove","Reset","Resume","Return","Right","RmDir","Rnd","SLN","SYD","SaveSetting","Second","Seek",
    "Select","SendKeys","Set","SetAttr","Sgn","Shell","Sin","Single","Space","Spc","Sqr","Static","Step","Stop","Str",
    "StrComp","StrConv","String","Sub","Switch","Tab","Tan","Then","Time","TimeSerial","TimeValue","Timer","To","Trim",
    "Type","TypeName","UBound","UCase","Unlock","Until","Val","VarType","Variant","Weekday","Wend","While","Width #",
    "With","Write #","Xor","Year",
    "Optional","InStrRev","Replace","Split","Join");

    function 
    visbasparse($text) {
      global 
    $kw;

      
    $text=str_replace("\\'""'"$text);

        
    $lines=explode("\n",$text);
        
    $val="";
        while (list(
    $brr,$line)=each($lines)) {

            if (
    substr(trim($line),0,1)=="'" or strtolower(substr(trim($line),0,4))=="rem ") {
                
    $line="<font color=\"#007F00\">$line</font>";
            } else {
                
    $quoteplace=strrpos($line,"'");
                if (
    $quoteplace>0) {
                    
    $beforequote=substr($line,0,$quoteplace);
                    if (
    countchar($beforequote,"\"")%2==0) {
                        
    $afterquote="<font color=\"#007F00\">".substr($line,$quoteplace)."</font>";
                        
    $codebit=$beforequote;
                    } else {
                        
    $afterquote="";
                        
    $codebit=$line;
                    }
                } else {
                    
    $afterquote="";
                    
    $codebit=$line;
                }

                
    reset ($kw);

                
    $codebit=" $codebit";
                while (list(
    $key,$keyword)=each($kw)) {

                    
    $codebit=ereg_replace("([\r\n\\(\\)>, .])$keyword([\r\n <,.$\\(\\)])","\\1<font color=\"#00007F\">$keyword</font>\\2",$codebit);

                }
                
    $codebit=substr($codebit,1);

                if (
    $afterquote!="") {
                    
    $line=$codebit.$afterquote;
                } else {
                    
    $line=$codebit;
                }
            }
            
    $val.=$line;
        }

      
    $val=str_replace("'""\'"$val);
      
    $val str_replace("\\\"","\"",$val);
      if (
    substr($val,0,1)=="\n" or substr($val,0,1)=="\r") {
        
    $val=substr($val,1);
      }
      return 
    "</normalfont><blockquote><pre><smallfont>visual basic code:</smallfont><hr>" str_replace("<br>"""$val) . "<hr></pre><normalfont></blockquote>";

    }

    ?>
    Users can then use [vbcode] tags to access this.

    I know that this is not very useful for many people, but it could be easily modified for other programming languages.

    John

    [edit - there's something funny going on with the slashes in the PHP code. Quote this message, and use the code straight from the reply window to get it accurately within any escaping problems.]
    Last edited by John; Sat 2nd Jun '01 at 1:10pm.
    John Percival

    Artificial intelligence usually beats real stupidity
     

Similar Threads

  1. Starting Visual Basic?
    By IDN in forum Chit Chat
    Replies: 21
    Last Post: Sat 19th Jun '04, 12:37am
  2. visual basic
    By Jake Bunce in forum Chit Chat
    Replies: 10
    Last Post: Tue 2nd Jul '02, 11:14pm
  3. Anybody here good at Visual Basic?
    By Hercules in forum Chit Chat
    Replies: 13
    Last Post: Wed 12th Jun '02, 10:40pm
  4. Visual Basic & PHP
    By JohnBradshaw in forum PHP & HTML Questions
    Replies: 6
    Last Post: Mon 13th Aug '01, 3:52pm
  5. ahahahahaha, VB=Visual Basic? :)
    By bira in forum vBulletin 1.1.x Suggestions and Feedback
    Replies: 2
    Last Post: Fri 21st Jul '00, 1:13pm

Bookmarks

Posting Permissions

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts