Please enable JavaScript to view this site.

Vensim Help

Navigation: Reference Guide > Functions

MESSAGE('msg',display) Display a MESSAGE

Scroll Prev Top Next More

Returns 0 if display is less than or equal to 0, 1 otherwise.

'msg' is the message to be displayed.  It must be either a literal surrounded by single quotes ' or a String variable.

The MESSAGE function is used to pass a message to the user in response to some condition in the model.  It can, for example, be used to put up a dialog informing the user that a certain condition has been met.  The way in which the message is displayed depends on the value of the display parameter.   If display is equal to 1 the message will go to the scrolling list of warnings.  If it is 2 a message box will come up with a informational prompt, 3 with a warning prompt and 4 with a stop prompt.

Because the MESSAGE function is most useful for putting up a single message it is typically used in conjunction with the SAMPLE IF TRUE function to be sure that the message only appears a single time.  The example below demonstrates how to do this.  The MESSAGE function is designed to work with any integration technique.  If you are using a Runge-Kutta integration technique it will not put up a message or return a non-zero value within an integration step.

Example

msg = SAMPLE IF TRUE(:NOT: msg,IF THEN ELSE(:NOT: msg :AND:

     project is started > 0,MESSAGE('Project Started',5),0),0) 

This will put up a message the first time the variable project is started takes on a non-zero value.

Availability: Not PLE or PLE Plus.

See also: SAMPLE IF TRUE

Sample model: MESSAGE.mdl and MESSAGE + SAMPLE IF TRUE.mdl in FunctionExamples