Using the editor


The Mads editor gets automatically activated when a file with the name extention ‘.mads’ gets created or opened from the Package Explorer or the navigator.

In addition to the standard editing functions available through the Edit menu or the corresponding key combinations (e.g. Ctrl-C and Ctrl-V for Cut and Paste), the editor provides for two very important key-commands:

The key services provided by the editor are syntax checking and content assist, data validation, and variable scope.


Syntax checking
Content assist
Data validation
Variable scope

Syntax Checking

Syntax checking means that anything typed in the editor that does not conform to the Mads syntax will be flagged by red marks in the editor, both in the left margin and under the word(s) causing the error. The editor will then be in ‘error condition’ and it will not be possible to run calculations till the error is corrected. This is illustrated below, where the keyword plan has been mis-typed.

Editor Error Condition

In addition, putting the cursor either over the wrong word or over the mark in the margin will display an error message. This is shown below. The message “no viable alternative at input 'plain'” tells us that this word has no meaning in the Mads syntax.

Editor Error Condition

Back to top

Content assist

The Content assist feature of the editor is triggered by the ctrl-space key combination. It will provide valid content proposals as well as templates for data entry, based on the position of the cursor in the text.

When a new .mads file is created manually, it is empty and the editor shows an error mark. Placing the cursor over the error mark will display the message: “mismatched input ' < EOF > ' expecting RULE_STRING”, meaning that string data is expected. Pressing by the ctrl-space key combination will display the following box:

Content Assist for an empty file

The first line of the box tells us that the editor expects a piece of text within simple or double quotes (a STRING) that would correspond to the variable “countryName”. A double-click on that first line of the box will insert “countryName” in the text, and create an error mark saying that the string should be followed by a semicolon. The proper value of the string can then be entered. The last two lines of the box tell us that it is also possible to insert keywords, namely Country name or Nom du Pays, before the string with the actual name value.

The second and third lines of the box tell us that the editor could insert one of two templates for header data / empty model – by a double-click on the corresponding line of the box – in the text. Important tip : if double-clicking does not seem to work, insert a space in the empty file and try again.

The templates for header data, that are shown in the Headers section of the MADS Grammar, show a number of fields that are ‘boxed’ and display some default value. The tab key will jump the cursor from one such field to the next, and when a list of alternative values exists then one can be selected from a drop-down list, as shown below:


The image above also shows the way optional sections are often handled in a template. The double interrogation mark ?? is an illegal input and that draws the attention of the user to the need to either keep and complete that section, including deleting the two ?? , or delete it all-together.

Back to top

Data validation

The editor makes the following checks on some of the data:

- Opportunity cost of capital: OCC must be > 0 and <= 100
- ExchangeRate must be > 0
- Project life must be > 0

Debt service function: Grace on interest cannot be > grace

Table attributes: ‘totals’ and ‘allColumns’ do not apply to BUDGET tables

Table years:
- Table years must be > 0 and within project life
- Table years must be in increasing order
- Budget Table: list of years must be 2 values at most

Plan: A plan cannot include itself, either directly or through nested plans

- Duration of age group classes must be > 0
- Initial and maximum size must be >= 0
- A data-by-cat section (i.e. ‘Parturition and milk’, ‘Intakes’, ‘Feed Requirements’ or ‘Other products and costs’) cannot include a herd class reference more than once

Back to top

Variable scope

In Mads all data entities as well as script variables are given a unique ID name. By default, any ID would be ‘visible’, i.e. could be used, anywhere in the model definition text. The editor modifies this default behavior as follows:

Back to top