Subweb Home
PLASMA Home
Overview
Template Syntax
Command Line
Template Tutorial
Worked Example
Code Style Guide
Schema Definition
Error Messages
Problem Reports
PARSEC Licence
Template Layout Stlye Guide
Good Practice

Several coding conventions have been developed to improve and standardize the format of Code Templates.

Template Header

The start of every template file should begin with a header. The header describes where the template belongs and what it does. They can also show when and how the template was last updated. A basic header is shown below.

    |
    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    ||
    || File Name:         ^PageHome.mcx
    || File Created:      MON-15-MAR-1999
    || File Version:      V1.0.0
    ||
    || System TLA:        WEB
    || System Name:       Website
    || System Title:      Simple Website Code Generator
    || System Purpose:    PLASMA*PARSEC Worked Example
    ||
    || Template Name:     HomePage
    || Template Code:     HTML
    || Templete Title:    Generate Home Page Code
    || Template Context:  <<<WEB_Page>>>
    || Template Purpose:  Produces code for the single Home page.  After the Logo
    ||                    and Banner are created, a blank menu area is coded.  The
    ||                    content area is formed from a number of rows (Navigation
    ||                    Block), each containing a number of Navigation Block
    ||                    Cells.
    ||
    || Copyright  Dark Matter Systems Ltd, 1994-2003.  All Rights Reserved.
    ||
    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Use of Indentation

Indentation of lines is used to arrange Template Code, never the generated source code. Lines should always be indented by 4 character positions. Indentations should occur when a new region is formed and the short form of the Comment Directive used to mark out the Directives. For example, the Template Code fragment below is used to create a table listing menu options for all menus available on every page:

    |
    <<<Template=MOT_Company>>>
        |
        <<<Template=MOT_Person>>>
            |
            <<<Template=MOT_Car>>>
                |
                <<<:>>><<<!05>>><<<#MOT_Company.Name>>>
                <<< >>><<<!21>>><<<#MOT_Person.Name>>>
                <<< >>><<<!37>>><<<#MOT_Car.Model>>>
                |
            <<<Endplate=MOT_Car>>>
            |
        <<<Endplate=MOT_Person>>>
        |
    <<<Endplate=MOT_Company>>>
    |
    <<<:>>>
    |

If possible, it is usually better practice to combine sequential Template Directives. For example, reformatting the example above gives shorter code with less indentation:

    |
    <<<Template=
    MOT_Company,
    MOT_Person,
    MOT_Car>>>
        |
        <<<:>>><<<!05>>><<<#MOT_Company.Name>>>
        <<< >>><<<!21>>><<<#MOT_Person.Name>>>
        <<< >>><<<!37>>><<<#MOT_Car.Model>>>
        |
    <<<Endplate=
    MOT_Company,
    MOT_Person,
    MOT_Car>>>
    |
    <<<:>>>
    |

Note how the potentially long output line has been broken up in the above example while preserving a clear layout by starting the code text in the same column on each line.

Warning: The two constructs are not strictly equivalent. Depending on the relationships between the objects and the attributes selected by the Data Directives the second construct may give rise to an error because there may exist more than one value (from more than object) for a selected attribute.

MON-10-NOV-2003