56 Chapter Three
If the EXITstatement has an optional WHENcondition, then the EXIT
statement only exits the loop if the condition specified is true. The next
statement executed depends on whether the EXITstatement has a loop
label specified or not. If a loop label is specified, the next statement executed
is contained in the LOOPstatement specified by the loop label. If no loop
label is present, the next statement executed is in the next outer loop. Here
is an example of an EXITstatement with a WHENcondition:
EXIT first_loop WHEN (i < 10);
This statement completes the execution of the loop labeled first_loop
when the expression i < 10is true.
The EXITstatement provides a quick and easy method of exiting a
LOOPstatement when all processing is finished or an error or warning
condition occurs.
ASSERT Statement
The ASSERTstatement is a very useful statement for reporting textual
strings to the designer. The ASSERTstatement checks the value of a
boolean expression for true or false. If the value is true, the statement
does nothing. If the value is false, the ASSERTstatement outputs a user-
specified text string to the standard output to the terminal.
The designer can also specify a severity level with which to output the
text string. The four levels are, in increasing level of severity, note, warn-
ing, error, and failure. The severity level gives the designer the ability to
classify messages into proper categories.
The note category is useful for relaying information to the user about
what is currently happening in the model. For instance, if the model had
a giant loop that took a long time to execute, an assertion of severity level
note could be used to notify the designer when the loop was 10 percent
complete, 20 percent complete, 30 percent complete, and so on.
Assertions of category warning can be used to alert the designer of con-
ditions that, although not catastrophic, can cause erroneous behavior
later. For instance, if a model expected a signal to be at a known value while
some process was executing, but the signal was at a different value, it may
not be an error as in the EXITstatement example, but a warning to the
user that results may not be as expected.