If statements, 4 if statements – Micromod MOD: 30ML Display Script Guide User Manual
Page 46

MOD 30ML Display Guide
Display Scripts
System Resources
Display Definition
Display Resource Name
Assigned Value and Displayed Result
Beeper
0 = Off
1 = On
3 - 65535 = Return to system definition
LED
0 = Off
1 = On
3 - 65535 = Return to system definition
Up/Down Arrows
0 = No display
1 = Up arrow
2 = Down arrow
3 = slash
4 = Up arrow and slash
5 = down arrow and slash
6 = Up arrow, down arrow and slash
7 - 65535 = Return to system definition
3.2.4 IF
Statements
IF-THEN-ELSE statements are used in display scripts based on key or display events.
The general format of the IF statement is:
IF-THEN-ELSE statement:
IF-THEN statement:
IF expression THEN
Statement 1;
ELSE
Statement 2;
IF expression THEN
Statement 1;
When an IF statement is used, the expression is evaluated. If it is true (that is, the value is
non-zero), statement1 is executed. If it is false (zero) and there is an ELSE, statement2 is
executed. If it is false (zero) and there is not an ELSE, execution continues with the
statement following the IF statement.
ELSE statements can also contain nested IF-THEN or IF-THEN-ELSE statements.
Because ELSE is optional, there is an ambiguity when an ELSE is omitted from a nested
IF sequence. This is resolved by associating the ELSE with the closest unmatched IF. In
the example on the left, the ELSE is matched with the second IF. In the example on the
right, braces are used to force the ELSE to be associated with the first IF.
3 - 8