PDA

View Full Version : Syntax highlight in forum [Code] posts

ErosOlmi
15-02-2006, 13:58
We have changed pnPhpBB forum source code in order to add syntax inside posted code. Before code block was all the same color.

An example of colored syntax:

[color=#0000FF]FUNCTION Factorial&#40;InVal AS QUAD&#41; AS EXT

r = 1
FOR i = 2 TO InVal
r = r * i
NEXT
FUNCTION = r

END FUNCTION

FUNCTION RecursiveExample&#40;n AS NUMBER, MaxRecurse AS NUMBER&#41; AS EXT
DIM s AS STRING VALUE REPEAT\$&#40;1000, "1"&#41;

IF n >= MaxRecurse THEN
FUNCTION = n
EXIT FUNCTION
ELSE
INCR n
FUNCTION = RecursiveExample&#40;n, MaxRecurse&#41;
END IF

END FUNCTION

DIM n AS NUMBER
n = 16
DIM f AS EXT = factorial&#40;n&#41;

MSGBOX&#40;0, "Factorial of " + n + " = " + f&#41;
MSGBOX&#40;0, "I've called a recursive function " + RecursiveExample&#40;1, 100&#41; + " times"&#41;

DIM msg AS STRING
DIM count AS LONG

FOR count = 1 TO 64
msg = msg + FORMAT\$&#40;Count,"000"&#41; & " &#91;" + FORMAT\$&#40;2^count,"#0"&#41; + "&#93;"
IF MOD&#40;count,2&#41; = 0 THEN
msg = msg + CRLF
ELSE
msg = msg + " "
END IF
NEXT
MSGBOX&#40;0, "From 2^1 to 2 ^ 64&#58;\n" + msg&#41;
MSGBOX 0, "RNDF&#58;" & RNDF&#40;10,20&#41;

We have also add a new option into thinAir IDE that will allow you to automatically produce BBCodes from a script. New thinAir option is under menu "Tools/BBCode to clipboard". Selected script text (or full script text in case of no selection) will be parsed and colored syntax put into computer clipboard. Then you will be able to directly paste inside forum posts.

We hope you will like it. Just wait for the next thinBasic 1.0.9.2 update.

Regards
Eros

Petr Schreiber
15-02-2006, 21:07
Hi,

what a surprise !
I like this new feature a lot !

Thanks,
Petr

catventure
15-02-2006, 21:31
I agree.

This is a very handy feature to have in ThinAir.

Regards,
catventure.

ErosOlmi
16-02-2006, 12:57
We take care of our users :D