User manual

228
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
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
Also, you can group values together for a match. Simply separate the items by commas:
select case reg
case 0
opmode = 0
case 1,2,3,4
opmode = 1
case 5,6,7
opmode = 2
end select
Nested Case Statements
Note that the select case statements can be nested values are then assigned to the innermost enclosing select
case statement.
Iteration Statements
Iteration statements let you loop a set of statements. There are three forms of iteration statements in mikroBasic PRO
for dsPIC30/33 and PIC24:
- for
- while
- do
You can use the statements break and continue to control the ow of a loop statement. break terminates the statement
in which it occurs, while continue begins executing the next iteration of the sequence.