# Running a model

A model is run, i.e. calculations are performed and results are produced, for a given plan.

One can run a model only if the editor content is valid and saved, and includes at least one Plan. To run a model, you first select a Plan, by double-clicking its name either in the editor or in the outline view. To run the selected plan click either the " MADS / Evaluate Selected Plan" menu sub-item in the menu-bar or the MADS icon in the tool-bar.

The entire set of calculation results is listed on the console. In addition, selected results are made visible in a user-defined way through the print commands that were specified through scripts included in plans, as explained in the Overview and detailed in the MADS Grammar section. Selected results (variables, tables, IRR function) can also be exported to an external ods-format spreadsheet file, as detailed in the Data Import-Export reference section.

In order to ensure that the data (i.e. source text) cannot be modified during a run, the system’s user interface will be locked during the run. Most of the time one would not even notice, it is primarily in the case of data export that the delay might be significant. If as an example you run a model that produces, displays in html and exports three large tables, you will first see progress as the text editor fills in, then the browser window will open and display the rendered tables, and remain frozen pending completion of the export operations. The progress of each export operation will be displayed in progress dialogues that will close down by themselves when the operation is complete, thus giving back control.

Depending on the value of the “Results as” attribute in the headers, the results will be produced in a text editor either in plain text or in web format (html code). The normal commands of the editor can be used to save and / or print the results. If the editor is saved, the output of a later model run will get appended.

### Plain output

A file named “mads_output.txt” gets either created or read – depending on whether it exists or not – in the project folder where the file that contains the Mads models is located. The file is opened by the default text editor, and the output is written into it, but not saved. It is formatted as plain text. If the editor is saved, the output of a later model run will get appended.

### Html output

A file named “mads_output.html” gets either created or read – depending on whether it exists or not – in the project folder where the file that contains the Mads models is located. The file is opened by the default text editor, and the output is written into it, but not saved. It is formatted as html source code. If the editor is saved, the output of a later model run will get appended.

In addition, the output gets rendered and displayed in a pop-up windows. If an other run is performed, the output in html code gets appended in the editor and a new pop-up windows displays the corresponding output.

The pop-up window(s) should be closed before leaving the application.

### Printing

There is no problem to print plain output or html code using the normal ‘print’ or ‘print as’ commands of the editor.

There is no command for printing the html rendered output, but it can be done using an external web browser such as Firefox or Internet Explorer. The steps are:

- Make sure that an external browser is available (menu Windows / Preferences / General / Web browser)
- Run the calculations on a given plan
- Close the pop-up windows where the output is displayed
- Save the “mads_output.html” file active in the editor
- Use the Project Explorer to right-click the “mads_output.html” file and use Open with... to select and external browser
- Use the normal browser print functions
- In case you do not want to keep results in the “mads_output.html” file, just delete it, it will get re-created next time you run a plan.

An other possibility is to export results (see Data Import-Export ) and use a spreadsheet software such as Open Office.