Change text in code tag box?

Simon Lloyd

New Member
Hi all,
I'm new here, i have very little php or html experience (i have owned a vbulletin forum since August) but i am learning fast and can perform whatever i am instructed to.

What i would like to do is change keywords found in the # code tags box, so instead of this:
Code:
Sub change()
for each r in range
if r = 0 then
msgbox "hello"
if r = 1 then
msgbox "goodbye"
end if
end if
next
end sub
i would like it to look like this:
Code:
[color=Blue]Sub[/color] change()
[color=blue]For Each [/color]r [color=blue]In Range[/color]
[color=White]>>>[/color][color=blue]If [/color]r = 0 [color=blue]Then[/color]
[color=white]>>>>>[/color]msgbox "hello"
[color=White]>>>>>>[/color][color=Blue]If[/color] r = 1 [color=blue]Then[/color]
[color=green]'Show a message to the user[/color]
[color=white]>>>>>>>>[/color]msgbox "goodbye"
[color=white]>>>>>>[/color][color=Blue]End If[/color]
[color=white]>>>[/color][color=blue]End If[/color]
[color=blue]Next[/color]
[color=blue]End Sub[/color]
Of course the above would be without the white chevrons, i had to use them to indent the code.

Here are my lists:
$bodykeywords=array("Application","AddressOf","Alias","And","Any","As","Binary","Boolean","ByRef",
"Byte","ByVal","Call","Case","CBool","CByte","CCur","CDate","CDbl","CInt","CLng","Close","Const",
"CSng","CStr","Currency","CVar","CVErr","Date","Debug","Declare","DefBool","DefByte","DefCur",
"DefDate","DefDbl","DefInt","DefLng","DefObj","DefSng","DefStr","DefVar","Dim","Do","Double"
,"Each","Else","End","Enum","Eqv","Erase","Error","Event","Exit","For","Friend","Function","Get",
"Global","GoSub","GoTo","If","Imp","Implements","In","Input","Integer","Is","LBound","Len","Let",
"Lib","Like","Line","Lock","Long","Loop","LSet","Mod","Msgbox","Name","New","Next","Not","Nothing",
"Null","Object","On","On Error Resume Next","Open","Option Base 1","Option Compare Binary",
"Option Compare Database","Option Compare Text","Option Explicit","Option Private Module","Optional","Or","Output","ParamArray","Preserve","Print","Private","Property","Public","Put",
"RaiseEvent","Random","Read","ReDim","Resume","Return","RSet","Seek","Select","Set","Single","Spc",
"Static","Step","Stop","String","Sub","Tab","Then","To","Type","UBound","Unlock","Variant","Wend","While"
"With","WithEvents","Write","Xor");
$indentkeywords = array("Then","Do","For Each","For","Else" "ElseIf","Do","Select Case","Case");
$unindentkeywords=array("End","Next","Else","ElseIf","End If","End Select","End Sub","Wend","Loop","Case Else","Case");

All the above keywords when found inside the code tags should be blue, any text found on the same line after ' should be green.

The indent keywords should indent like my second example only returning to the begining of a line if an unindent keyword is found or only indenting another line when another indent keyword is found.

I have installed GeSHi which highlights the code if i use a custom tag but it doesn't indent or replace the words for the words in the list (proper case).

Is this possible with php, javascript and or CSS?

Kind regards,
Simon
 
Hmm I have really no clue about what you are talking from. The Code you mentioned is Visual Basic (VB) and has nothing to do with vBulletin.
 
Yes, i know it has nothing to do with vbulletin. Currently in vbulletin we use the # to surround code with code tags, which will display code as per my first code box in the first post, but, based on keywords i would like the words replaced with the actual case of the keyword and coloured Blue so range would be come Range, also if an indent keyword is found then indent lets say 2 spaces or a tab, the next line of code should then also be indented that far unless another indent keyword is found (indent again 2 spaces or a tab) or an unindent keyword is present, the end result would look like my second code box.

Does this help?

Kind regards,
SImon
 
Back
Top