Rice Lake iRite IDE User Manual
Page 28

24
920i
Programming Reference
The if-else is used when the program must decide which of exactly two different paths of execution must be
executed. The path that will execute the statement or statements in
if iAge => 18 then
sStatus := "Adult";
else
sStatus := "Minor";
end if;
If the statement is false, then the statement or statements in
expression is evaluated and one of the paths is chosen, the expression is not evaluated again. This means the
statement will terminate after one of the paths has been executed.
For example, if the expression was true and we were executing
ELSIF
expr
stmt-list
THEN
Figure 3-14. Optional Else-If Statement Syntax
The if-elsif version is used when a multi-way decision is necessary and has this general form:
if
elsif
elsif
elsif
else
end if;
Here is an example of the if-elsif form:
if rWeight <= 2.0 then
iGrade := 1;
elsif (rWeight > 2.0) and (rWeight < 4.5) then
iGrade := 2;
elsif (rWeight > 4.5) and (rWeight < 9.25) then
iGrade := 3;
elsif (rWeight > 9.25) and (rWeight < 11.875) then
iGrade := 4;
else
iGrade := 0;
sErrorString := "Invalid Weight!";
end if;