Batch Mode Simulation : Structured SCL Statements : WHEN/THEN/ELSE Statement

WHEN/THEN/ELSE Statement

The WHEN/THEN/ELSE Statement is used for execution of SCL statements upon the occurrence of an event.

WHEN event_expression

THEN statement [ ; statement . . . ]

ELSE statement [ ; statement . . . ]

END WHEN

In this structured statement, the statements following the THEN and before the ELSE are executed if the event_expression is true. If false, the statements following the ELSE are executed. The event_expression may include references to Rational Statemate elements as well as SCL variables and constants.

For example:
WHEN entered(A) [level>20] THEN
WRITE (’too high level when A entered \n’)
ELSE
WHEN entered(A)
WRITE (’running normally \n’)
END WHEN;
END WHEN;