AutoLISP Syntax Highlighter on the forums

Started by BazzaCAD, March 18, 2009, 04:44:50 PM

Previous topic - Next topic

BazzaCAD

With some hard work from Owen (and myself), we now have a CODE tag that will automatically highlight your AutoLISP & OpenDCL code.
Here's a small example.

Code (autolisp) Select

;;This is a comment
(setq a 5)
(setq b (1+ a))
(setq c "this is a string")
(vl-load-com)
(OR (dcl_PROJECT_LOAD "Proj1" T) (EXIT))
(dcl_Form_Show Proj1_Form1)


Try not to paste super huge of code blocks. About 200 lines is the max. without bogging down the page load.

All you have to do is hit the CODE button, now renames to "Insert AutoLISP code" (see image below), then paste your code in between the CODE tags.
If you still need the old generic code block without the Highlighting, just remove the =autolisp from the tag.

You'll notice some of the special operators "+ 1+ * - 1- / = < > <= >=" etc.. & ;| multi-line comments |; don't highlight.


a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

Kerry


Excellent Result Barry abd Owen.

Did you get the MultiLine comment sorted ?? or is it too process intensive ?
Perfection is not optional.
My other home is TheSwamp

owenwengerd

I had it in there, but it bogged things down too much, so I removed it again.

xshrimp

#3
bug?? &#59
how to fix?


Code (autolisp) Select
(setq a (strcat ";" a));add a ";" in front of the string if not already present  
(not (wcmatch a (strcat "*;" b ";*"))) ;is 'dir' already present in search path?  


owenwengerd


qjchen

#5
~~ Thank you, great.
Let me test
Code (autolisp) Select

;;; and lwpolyline
if (> a b )
(defun objectpoint_text (obj);;;;test
 (if (= (cdr (assoc 0 obj)) "TEXT")
   (tbox-cab obj)
 )
)
(setq textHeight (vlax-get (vlax-ename->vla-object x) 'Height))



I am also learning how to use SyntaxHighlighter 3.0.83 in my pages
but I find that when I use this
this.regexList = [
            { regex:  /;.*$/gm,                   css: 'comments'  },
then, in the highlight, all < is convert into <;   and > into >;    vlax-ename->vla-object x   into vlax-ename->;vla-object x

but in your great site, there is no problem exist, great~

owenwengerd

It gets complicated because special characters will be represented as HTML codes (i.e. &lt;) in the raw HTML.