stopsimulation

Navigation:  Language Reference > Statements >

stopsimulation

Previous pageReturn to chapter overviewNext page

Syntax

stopsimulation ('string');

Description

The stopsimulation function stops the simulation as soon as it comes to action. It is useful when used in combination with an if statement. As soon as the simulation stops, the log window will appear showing the string that is used in the function.

 

Normal stop: If the string starts with 'Error', the Simulator will stop and the Editor will jump to the the model containing the stopsimulation function.
Silent stop: If the string does not start with 'Error' the Simulation will jump to the finalequations section, execute them and stop the simulation.

Examples

In the example below the Simulator will stop the simulation at time > 6 and show a message 'time > 6' in the output tab. The finalequations are evaluated and number has a value of 2:

 

variables

 integer number;

initialequations

 number = 1;

equations

 if time > 6 then

         stopsimulation ('time > 6' );

 end;

finalequations

 number = 2;

 

In the example below the Simulator will stop the simulation at time > 6 and show a message 'time > 6' in the output tab. The Editor will jump to this model showing an error message. The finalequations are not evaluated and number has a value of 1:

 

variables

 integer number;

initialequations

 number = 1;

equations

 if time > 6 then

         stopsimulation ('Error time > 6' );

 end;

finalequations

 number = 2;