Mikroelektronika MIKROE-724 データシート
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
227
The compiler treats the construction in this way:
if expression1 then
if expression2 then
statement1
else
statement2
end if
end if
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.