Datasheet

In order to force the compiler to interpret our example the other way around, we
have to write it explicitly:
if expression1 then
if expression2 then
statement1
end if
else
statement2
end if
SELECT CASE STATEMENT
Use the select case statement to pass control to a specific program branch, based
on a certain condition. The select case statement consists of selector expression
(condition) and list of possible values. The syntax of the select case statement is:
select case selector
case value_1
statements_1
...
case value_n
statements_n
[case else
default_statements]
end select
selector
is an expression which should evaluate as integral value. values can be
literals, constants or expressions and statements can be any statements. The case
else
clause is optional.
First, the
selector expression (condition) is evaluated. The select case statement
then compares it against all available values. If the match is found, the statements
following the match evaluate, and the select case statement terminates. In case
there are multiple matches, the first matching statement will be executed. If none of
the values matches the selector, then default_statements in the case else
clause (if there is one) are executed.
Here is a simple example of the select case statement:
select case operator
case "*"
res = n1 * n2
case "/"
res = n1 / n2
case "+"
res = n1 + n2
case "-"
res = n1 - n2
case else
res = 0
cnt = cnt + 1
end select
154
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroBasic PRO for AVR
CHAPTER 5