Case statements, 5 case statements – Micromod MOD: 30ML Display Script Guide User Manual
Page 47

MOD 30ML Display Guide
Display Scripts
IF I1 > 0 THEN
IF I2 > I3 THEN
I2 + 1
ELSE
I3 + 1
IF I1 > 0 THEN
{
IF I2 > I3 THEN
I2 + 1
}
ELSE
I3 + 1
In the example below, an IF-THEN-ELSE statement is combined with an assignment
statement to toggle the value of a local display input, named SCRLCNT, between 1 and 0
each time the Scroll key is pressed:
SCROLL_PRESSED:
{
IF SCRLCNT >= 1 THEN
SCRLCNT = 0;
ELSE
SCRLCNT = SCRLCNT + 1;
3.2.5 CASE
Statements
The CASE statement presents a list of labels and associated statements. The value of the
expression is compared with these labels. If a match is found, the associated statements
are executed. If no match is found, the default statements are executed. The default case
is optional – if it is not present and no other match is found, no statements are executed.
The general format of the CASE statement is:
CASE expression OF
{
Label1:
Statement1;
Label2:
Statement2;
.
.
.
LabelN:
StatemetnN;
DEFAULT:
StatementM;
}
The cases can be listed in any order. The integer labels must be unique and must be in the
range of 0 to 65535. Up to 255 cases may be present, not including the default case. If
the expression evaluates to a value outside the range 0 to 65535, the default case is
executed, if present.
The BREAK statement causes immediate exit from a CASE statement. As a general rule,
the last statement for each case should be a BREAK statement, although it is not required.
After the statements associated with the case are done, execution continues with the
statements for the next case unless a BREAK statement is present to prevent this.
3 - 9