Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BBCoder tool available

Status
Not open for further replies.

Griffyn

Programmer
Joined
Jul 11, 2002
Messages
1,077
Location
AU
Hi all,

I'm primarily a Delphi programmer, and I've made available a little tool I use to add syntax highlighting to my code examples. It can also handle VB, and can be quickly set up for others too. I spend most of my time in the Delphi forum, and a lot of people are really liking this tool.

It comes as both a stand-alone tool, as well as an optional Browser Helper Object that once installed (IE only), will automatically add syntax highlighting whenever you post a reply that contains a code example (using the [ignore]
Code:
[/ignore] blocks).

eg.
Code:
[green][i]' for automatic syntax highlighting see faq102-6487 
[/i][/green][b]Private[/b] [b]Sub[/b] WorkChange([b]ByVal[/b] Target [b]As[/b] Sheet)
    [b]Dim[/b] rReserve [b]As[/b] Range, rDisplay [b]As[/b] Range
[green][i]' set range
[/i][/green]    [b]Set[/b] rReserve = Range([navy]"A:Z"[/navy]) [green][i]'prices get entered in these columns
[/i][/green]    [b]Set[/b] rng = Application.Intersect(Target.EntireRow, rReserve)
    [b]If[/b] [b]Not[/b] rng [b]Is[/b] [b]Nothing[/b] [b]Then[/b]
        [b]For[/b] [b]Each[/b] r [b]In[/b] rng
            [b]If[/b] IsEmpty(r.Value) [b]Then[/b] [b]Exit[/b] [b]For[/b]
            nThis = r.Value
        [b]Next[/b]
    [b]End[/b] [b]If[/b]

I think it really aids readability, particularly for large or complex code examples. The colours and formatting are completely customisable.

Download from here if you like For any issues with it, I can be contacted through the faq topic. faq102-6487
 
Nice piece of coding!

You should note that "REM" as a comment identifier is finding every occurrence of REM so something like
Code:
Premium = 100
gets translated to
Code:
P[red][i]remium = 100 [/i][/red]
I've changed the comment color from green to red to make it stand out.
 
It also results in things like this because it is trying to embed a comment within a comment.

Formatted code
[ignore]
Code:
[red][i]' for automatic syntax highlighting see faq102-6487 
[/i][/red]P[red][i]remium = 55
[/i][/red][red][i]' This is the p[red][i]remium [/i][/red]
[/ignore]

Result
Code:
[red][i]' for automatic syntax highlighting see faq102-6487 
[/i][/red]P[red][i]remium = 55
[/i][/red][red][i]' This is the p[red][i]remium [/i][/red]
 
Hi Golom,

I've fixed those issues, the parsing rules change slightly when words can begin comments (Delphi only uses symbols). Download the archive again from the link above for the updated programs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top