Home page Home page Home page Home page
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel
By Captain C | Friday, 22 May 2009 11:05 | 0 Comments
With the addition of this blog to our website we soon found the need to publish Basic+ source code along with technical articles, and, being bored of plain <pre> tags, we decided write a tool that would allow us to easily generate HTML for syntax-coloured Basic+ code. We also wanted something we could use on the Revelation Forum as well as on the blog.

Well, after digging up some old prototype syntax highlighting code and wrapping it in a simple form, the "Sprezzatura Basic+ Source Code HTML Publisher" was born. The bad news is the awful title - the good news is that we're giving it away so you can use it yourself if you wish. The rest of this post simply describes how to use it - if you want a copy then simply drop us a line and we'll send you one.

The installation is a standard setup.exe compiled with the RDK/NSIS on OI9, so it will ask you the usual questions such as the location of the target OI system and the login credentials etc. The software will be copied into the SYSPROG application - once you've got it installed into your copy of OI execute the ZZ_IDE_BP_PUBLISHER form to launch the Publisher.

Using the Publisher

The Publisher is composed of four tabs - publishing your Basic+ code to HTML is simply a matter of following this sequence:

  1. Enter the Basic+ source code you wish to publish in the Source Code tab.
  2. Click on the Styling Options tab and adjust any required CSS options.
  3. Click on the HTML Code tab to generate the actual HTML you will need to embed in your forum post - you can copy and paste this code as you wish.
  4. Click on the HTML Preview Tab to see how the generated HTML will look in a browser.

Source Code Tab

Use this tab to enter the source code you wish to publish. You can enter it directly, paste it from the clipboard, or use the "Open" button to load the contents of a Stored Procedure or Insert from the repository.

Styling Options Tab

This tab lets you define how you want your source formatted when it's published to HTML.

StyleSheet Options: This settings allows you to specify how you wish to use CSS with your published source code. You can use one of the following options:
  1. Generate in-line style tags: All CSS styling will be embedded within each HTML tag via a "style" attribute.
  2. Generate an embedded style sheet: The Publisher creates and embeds a stylesheet within a "style" tag containing the CSS attributes to apply to the source code. All the HTML in the source code tags use a "class" attribute to refer to the CSS in the embedded stylesheet. A list of class names used by the publisher is given at the end of this post.
  3. Generate class names only: The Publisher simply adds CSS class names to the source code HTML tags but doesn't generate an embedded stylesheet. The actual CSS is expected to be referenced and contained in an external stylesheet page. When using this option it is not possible to specify any individual CSS formatting for the source code, and the relevant sections of the tab page are disabled.
Use Link URL: This option is only enabled when Stylesheet Options is set to "Generate class names only". If a URL is entered here a <link> tag is added to the generated HTML that references the URL.

Add [ ] brackets: This option adds a "[" character to the beginning of the generated HTML and an "]" character afterwards. These two characters are necessary when adding your published source code to the revelation.com forum - when making a post anything between these two characters is considered to be raw HTML to be embedded in the posting. Without these it is considered to be text.

Overall CSS formatting: This group of options is applied to the <div> tag that surrounds the published source code. There are prompts for the most common CSS requirements, and a miscellaneous tag to allow ad-hoc CSS styles to be applied as required.

Syntax-specific CSS formatting: This group of options controls the formatting applied to each type of token found in the Basic+ code. Again, there are prompts for the most common CSS requirements, and a miscellaneous tag to allow ad-hoc CSS styles to be applied as required.

Replace tabs: When the Basic+ code is formatted to HTML all tab characters are translated to non-breaking space characters. This option allows you to specify how many spaces are used per tab character.

Include Line Numbers: Check this option to include line numbers in the published source code.

Save Styling Options: Click this button to save the styling options to a record in the SYSENV table. The Publisher automatically loads saved styling options when the form is created. Styling options are saved with a key structure like so:


If no user specific config record is found the Publisher attempts to load an application specific one:


The application inheritance chain is respected.

HTML Code Tab

When you click on this tab the Publisher processes the Basic+ source code and applies the CSS styling - the result is displayed in this tab.

Copy To Clipboard: This button copies the entire text to the clipboard so you can paste it into your post.

Save As: This button creates a very basic HTML document that contains the generated HTML and allows you to save it to disk.

HTML Preview Tab

This tab uses the ActiveX WebBrowser control to display a preview of the generated HTML.

Keywords and Styling

When the publisher processes your Basic+ code it breaks it up into tokens and applies the relevant CSS to each token found. If you elect to use a stylesheet with your source code rather than inline-styling a CSS class name is applied to each token. The CSS class name of each token and the type of token it applies to is listed below:

Syntax Token TypeCSS Class Name
Compiler DirectivebpDirective
System VariablebpSysVar
Debug StatementbpDebug
Dictionary FieldbpDict
Subroutine LabelbpLabel
Line NumberbpLineNo

The list of keywords using for publishing is contained in a record in the SYSENV table called CFG_ZZ_TCL_EDIT_BP_KEYWORDS. This record has four fields, each of which contain a multivalued list of words:
  1. Basic+ keywords
  2. System variable (@var) names
  3. Compiler directives (#define etc...)
  4. Debugger directives (i.e. the debug statement)

Labels: , , ,


Post a Comment

Subscribe to Post Comments [Atom]

<< Home

Pixel Footer R1 C1 Pixel