Welcome to Dream.In.Code
Getting Help is Easy!

Join 86,242 Programmers. There are 2,257 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

Syntax Highlighting Now Available on DIC!

7 Pages V  1 2 3 > »   
Reply to this topicStart new topic

Syntax Highlighting Now Available on DIC!

skyhawk133
post 20 Feb, 2008 - 07:55 PM
Post #1


Big Money... No Wammies!

Group Icon
Joined: 17 Mar, 2001
Posts: 13,547



Alrighty, EVERYONE has asked for this at least once, and up until now I did not have a good solution, but tonight, I present to you.... syntax highlighting in the forums!

The old [code] tag is still available, but now you can use [code=language] to highlight the code you're posting.

Here's an example:
[code=php]echo 'Hello World';[/code]

Looks like this:

php
echo 'Hello World';



Or a little better example, this time using "cpp" for the language:

cpp
string StringToUpper(string strToConvert)
{//change each element of the string to upper case
for(unsigned int i=0;i {
strToConvert[i] = toupper(strToConvert[i]);
}
return strToConvert;//return the converted string
}

string StringToLower(string strToConvert)
{//change each element of the string to lower case
for(unsigned int i=0;i {
strToConvert[i] = tolower(strToConvert[i]);
}
return strToConvert;//return the converted string
}


You MUST type the language in all lower case, and it MUST be one of the following languages:
  • cpp
  • csharp
  • css
  • delphi
  • java
  • jscript
  • php
  • python
  • ruby
  • sql
  • vb
  • xml
So just another example of how to use the new code tag: [code=vb] would highlight Visual Basic, or (I believe) VB.NET, and [code=csharp] will highlight in C# mode.

Go ahead and test it out in this thread, and start using it when you post!!!

Enjoy.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


csmanoj
post 20 Feb, 2008 - 07:58 PM
Post #2


D.I.C Head

Group Icon
Joined: 6 Aug, 2007
Posts: 107

Oh wow that's awesome!

cpp

int SayIt(int number)
{
int i = number;
string s = "Great feature";
while(i>0)
{
cout<<s<<endl;
i--;
}
cout<<"I've said it "<<number<<" times.\n";
return 0;
}


This post has been edited by csmanoj: 20 Feb, 2008 - 08:04 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Louisda16th
post 20 Feb, 2008 - 08:00 PM
Post #3


DIC Maniac

Group Icon
Joined: 3 Aug, 2006
Posts: 1,786

Yay! Finally its here! This is something I've been looking forward to. Great work Chris. smile.gif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

RodgerB
post 20 Feb, 2008 - 08:04 PM
Post #4


D.I.C Lover

Group Icon
Joined: 21 Sep, 2007
Posts: 1,458

Thanks very much for this, it was a much needed feature (for me anyway, it really helps me to be able to read code with colour). smile.gif

vb

While i < 5
Console.WriteLine("LOLZ")
i += 1
End While


Ah the fun.
User is online!Profile CardPM
Go to the top of the page
+Quote Post

Mikhail
post 20 Feb, 2008 - 08:09 PM
Post #5


D.I.C Addict

Group Icon
Joined: 26 Oct, 2007
Posts: 619

It does work! Thanks to whoever made this.

cpp
#include <stdio.h>

int main(void)
{
printf ("Hello World \n");

return 0;
}
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Nykc
post 20 Feb, 2008 - 08:10 PM
Post #6


DIC == Huge!

Group Icon
Joined: 14 Sep, 2007
Posts: 2,293

jscript

document.write('This is pretty slick');




This post has been edited by Nykc: 20 Feb, 2008 - 08:12 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Louisda16th
post 20 Feb, 2008 - 08:17 PM
Post #7


DIC Maniac

Group Icon
Joined: 3 Aug, 2006
Posts: 1,786

vb


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n As Integer 'Number of rows
Dim i As Integer, j As Integer 'Counters
Dim term As Integer

Dim CurrRow() As Integer 'Current Row
Dim NextRow() As Integer 'Next Row

n = Val(InputBox("Enter number of rows"))

ReDim CurrRow(2)
ReDim NextRow(3)
CurrRow(1) = 1

For i = 1 To n
TextBox1.Text += Space(n - i)
For j = 1 To i
term = CurrRow(j - 1) + CurrRow(j)
TextBox1.Text += Str(term)
NextRow(j) = term
Next j
TextBox1.Text += vbNewLine
ReDim CurrRow(i + 2)
CurrRow = NextRow
ReDim NextRow(i + 3)
Next i
End Sub

I llove this biggrin.gif!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

bhandari
post 20 Feb, 2008 - 11:17 PM
Post #8


D.I.C Addict

Group Icon
Joined: 31 Jan, 2008
Posts: 745

java
System.out.println("Is this really good");


yes it is....
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

TheMagnitude
post 21 Feb, 2008 - 12:22 AM
Post #9


D.I.C Head

Group Icon
Joined: 12 Jan, 2008
Posts: 87

Nice work!!!!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

PennyBoki
post 21 Feb, 2008 - 12:32 AM
Post #10


system("revolution");

Group Icon
Joined: 11 Dec, 2006
Posts: 2,006

It looks really cool. But I have a question though, when we ask new users to use code tags, should we ask them to use syntax highlighting or just the plain old code.gif?

I think only the answerers of the questions will use this feature. Anyways it looks cool like this, I like it smile.gif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

jayman9
post 21 Feb, 2008 - 12:38 AM
Post #11


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 5,543

PennyBoki, as long as they at least use the code tags I don't really care.

The key is just to get them to use them period.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

MitkOK
post 21 Feb, 2008 - 01:19 AM
Post #12


D.I.C Head

Group Icon
Joined: 9 Aug, 2007
Posts: 102

ruby
class Welcome

def sayHello
puts "Working nice !"
end

end
User is online!Profile CardPM
Go to the top of the page
+Quote Post

7 Pages V  1 2 3 > » 
Fast ReplyReply to this topicStart new topic
Time is now: 5/16/08 08:18AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month