Subscribe via RSS Feed Connect on LinkedIn

CAL Syntax Highlighter for WordPress

15th March 2015 0 Comments

This website like 20% of all new websites and blogs is run on the WordPress platform, as the subject is Dynamics NAV it helps to add code that could be copied and pasted, Dynamics NAV uses the C/AL Language (Client/server Application Language) otherwise known as CSide which stands for Client Server Integrated Environment.

There are a number of Syntax Highlighter plugins available for WordPress but no support for the C/AL Language, this means when code examples are added to posts the Syntax Highlighting is often coloured wrong, having done a little WordPress and php coding for my own projects I have created a Plugin to extend the Syntax Highlighter Evolved plugin by Alex Mills.

To use this Plugin you will need a WordPress website where you can load plugins, install the Syntax Highlighter Evolved Plugin, download and install my plugin “syntaxhighlighter-evolved-cside-brush” from the WordPress plugins or downloaded from the end of this post, then you are ready to go.

Load Plugins

Plugins > Add New, enter syntaxhighlighter into the searchbox Install and Activate the Syntax Highlighter Evolved Plugin by Alex Mills.

Snap 2015-03-15 at 08.06.12

From the Plugins Menu upload, or Search for “syntaxhighlighter cside”, Install and Activate my Plugin which can also be downloaded from the end of this post.

Snap 2015-03-26 at 06.29.30

Then you will have two plugins activated.

Snap 2015-03-15 at 08.14.02

 

Using the Syntax Highlighter

The older versions of Navision did not have Syntax Highlighting just plain black text, the later versions have blue keywords and brown text within single quotes.

Snap 2015-03-15 at 14.45.09

Snap 2015-03-15 at 14.45.23

Indentation and Comments

In Dynamics NAV the Indentation is not a real TAB but a double space, when the C/AL code is pasted and saved it will lose the indentation, it is a shame but I have to save the post as draft and add the indentation to the code manually with spaces.

I have also coloured the Block comments, this feature I feed is missing in Dynamics NAV.

Syntax Highligher without the C/AL, Cside Plugin

Snap 2015-03-15 at 15.00.04

 

CLEAR(PrinterSelection);

IF NOT PrinterSelection.GET(USERID,ReportID) THEN
  IF NOT PrinterSelection.GET('',ReportID) THEN
    IF NOT PrinterSelection.GET(USERID,0) THEN
      IF PrinterSelection.GET('',0) THEN;

EXIT(PrinterSelection."Printer Name");

 

With Shortcode cal, nav, navision, cside

Snap 2015-03-15 at 15.28.15

 

//Comment String Example

//Comment Block Example

{

IF NOT PrinterSelection.GET(USERID,ReportID) THEN
  IF NOT PrinterSelection.GET('',ReportID) THEN

}

CLEAR(PrinterSelection);

IF NOT PrinterSelection.GET(USERID,ReportID) THEN
  IF NOT PrinterSelection.GET('',ReportID) THEN
    IF NOT PrinterSelection.GET(USERID,0) THEN
      IF PrinterSelection.GET('',0) THEN;

EXIT(PrinterSelection."Printer Name");

 

With Language (Cside) and Title

Snap 2015-03-15 at 15.28.44

 

CLEAR(PrinterSelection);

IF NOT PrinterSelection.GET(USERID,ReportID) THEN
  IF NOT PrinterSelection.GET('',ReportID) THEN
    IF NOT PrinterSelection.GET(USERID,0) THEN
      IF PrinterSelection.GET('',0) THEN;

EXIT(PrinterSelection."Printer Name");

 

With Language (Cside) ,Title and Collapsed Box

Snap 2015-03-15 at 15.29.10

Click Title to Expand.


EXIT('GB Dynamics NAV 7.1');

Download “Syntax Highlighter Evolved CSide Brush” syntaxhighlighter-evolved-dynamics-nav-cside-brush.zip – Downloaded 1104 times – 23 KB

Leave a Reply

You must be logged in to post a comment.