Somebody knows where I can get such a script.
Code:Dim blat as String
VB Code:
Dim blat as string
Printable View
Somebody knows where I can get such a script.
Code:Dim blat as String
VB Code:
Dim blat as string
no you have to make it.
If it's any help, here's a vBulletin hack, same as the one used here to make [Highlight=VB]: http://www.vbulletin.org/forum/showt...ghlight=vbcode
that's it arien give him a link he can't see. good job :p
I created a program that does this and converts it to HTML. The thing is, it'd have to be predone.
But basically what I did was.
Replace occurances of '.', '(', and ')' with spaced versions, ie ' . ', ' ( ', and ' ) '. After that I split up the string of code by newline characters. Than I ran each line through code, split it using a space (" ") as a deliminator. I then cycled through each word in the sentence and compared it to an array of reserved words, if they matched it through tags on the beginning and end, and did nothing if it didnt. It built the line back up as it went through each word, then also built the whole chunk of code back up as it finished each line.
Finally, I replaced the ' . ', ' ( ', and ' ) ' back with '.', '(', and ')'
If you don't understand anything I said, then just forget it all and don't try to understand.
Here's a start. See what you can do with this:
PHP Code:<?php
$code = "Private Sub Form_Load()\nDim x As Integer";
$reserved = Array("Private", "Sub", "Dim", "As", "Integer");
$numr = count($reserved);
$lines = explode("\n", $code);
$numl = count($lines);
//for each line
for ($i = 0; $i < $numl; $i++) {
$words = explode(' ', $lines[$i]);
$numw = count($words);
$line = '';
//for each word
for ($j = 0; $j < $numw; $j++) {
$b = 0;
//for each reserved word
for ($k = 0; $k < $numr; $k++) {
if ($words[$j] == $reserved[$k]) {
$b = 1;
$line = $line . '<font color="blue">' . $words[$j] . ' </font>';
}
}
if ($b != 1) {
$line = $line . $words[$j] . ' ';
}
}
$fcode = $fcode . $line . "<br>";
}
echo $fcode;
?>
I just added a little to handle commments. Maybe someone can make this more efficient:
Let me know if this helps or if you need anything more.PHP Code:<?php
$code = "Private Sub Form_Load()\nDim x As Integer\n 'this is our sample comment\n\nEnd Sub";
$reserved = Array("Private", "Sub", "Dim", "As", "Integer", "End");
$numr = count($reserved);
$code = str_replace('(', ' ( ', $code);
$code = str_replace(')', ' ) ', $code);
$code = str_replace('.', ' . ', $code);
$code = str_replace("'", " ' ", $code);
$lines = explode("\n", $code);
$numl = count($lines);
//for each line
for ($i = 0; $i < $numl; $i++) {
$words = explode(' ', $lines[$i]);
$numw = count($words);
$line = '';
//for each word
for ($j = 0; $j < $numw; $j++) {
$b = 0;
if($words[$j] == "'") {
$line = $line . '<font color="green">';
for ($m = $j; $m < $numw; $m++) {
$line = $line . $words[$m] . ' ';
}
$line = $line . "</font>";
break;
}
//for each reserved word
for ($k = 0; $k < $numr; $k++) {
if ($words[$j] == $reserved[$k]) {
$b = 1;
$line = $line . '<font color="blue">' . $words[$j] . ' </font>';
}
}
if ($b != 1) {
$line = $line . $words[$j] . ' ';
}
}
$fcode = $fcode . $line . "<br>";
}
$fcode = str_replace(' ( ', '(', $fcode);
$fcode= str_replace(' ) ', ')', $fcode);
$fcode = str_replace(' . ', '.', $fcode);
$fcode = str_replace(" ' ", "'", $fcode);
echo "<pre>$fcode</pre>";
?>
don't you hate reformatting and not backing up :O
i had written a function for this, don't know where it is now and can't be bothered to re write D:
Thx for all your replies. I know I can make something myself, but I'm just to lazy to make a good script for this. It's even for myself but for somebody elses site. I was just curious if I could down this script somewhere, but it turns out I can't..
Thx again
Is there something wrong with the code I posted above?
The Hobo: I think youd look better without the pimpish-avatar :) anyway, I guess this doesn't have anything to do with the post, but just please change it :) :) :p btw, is that you w/ a photoshop edited mustache :)
Please post any inquires about my facial hair in the designated thread. Thank you.
lol, ill make sure to do that..hehe