General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 9th, 2004, 09:16 AM
harvey_r01 harvey_r01 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Bournemouth
Posts: 37 harvey_r01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Recognising code

Hi All,

I'm writing a forum for a PHP site i'm building and would like the facility of users typing in code and the site to be able to recognise the functions in the code. The same way in which this forum works i.e. using the "
PHP Code:
" and " 
" tags which recognise all php funcs and displays in a colour coded fashion. I would like this facility for PHP, JSP, ASP, Java, C++ and C code.

The part i'm hazy on is recognising the functions within the specified tags. So my question really is, how do i compare elements in a string to PHP/JSP/ASP/Java/C++ and C functions?

All help is greatly appreciated...

Cheers,
Harvey

Reply With Quote
  #2  
Old January 9th, 2004, 11:58 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Your best answer to this would be to find a dictionary file already written for each language... I used to use a program called textpad that allowed you to download add-ons that would highlight code based on keywords... I believe these addons were simply text-based... Perhaps they would be of use to you...

Once you have the keyword dictionaries, its just a simple search/replace for the colour coding...

Reply With Quote
  #3  
Old January 10th, 2004, 10:31 AM
harvey_r01 harvey_r01 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Bournemouth
Posts: 37 harvey_r01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Hi MadCowDzz,

cheers for the tip with textpad. I've been using it for years and never realised all C/C++/Java/HTML/CSS code elements were simply stored in syn files. Great tip!!

But unfortunately it doesn't have a PHP file. Does anybody know where I could get this from?

Many Thanks,
Harvey

Reply With Quote
  #4  
Old January 10th, 2004, 12:14 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
textpad's website offers new libraries and addons...
http://www.textpad.com/add-ons/index.html

there's a wide variety of languages offered...

The php syntax definition in particular is located on this url:
http://www.textpad.com/add-ons/synn2t.html (about a third of the way down the page)

Reply With Quote
  #5  
Old January 10th, 2004, 04:15 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Try using highlight_file() function for php..
__________________
ExoHelpDesk
ExoCrew Free Services

Reply With Quote
  #6  
Old January 10th, 2004, 06:22 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
highlight_file() would work for the PHP code, but not JSP/ASP/Java/C++ and so on

Its an interesting function though, I didn't know it existed... thanks for the post mike_r
http://www.php.net/manual/en/functi...hlight-file.php

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Recognising code


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT