User manual
228
mikoBasic PRO for PIC32
MikroElektronika
Do Statement
The do statement executes until the condition becomes true. The syntax of the do statement is:
do
statements
loop until expression
statements are executed repeatedly until expression evaluates true. expression is evaluated after each
iteration, so the loop will execute statements at least once.
Here is an example of calculating scalar product of two vectors, using the do statement:
s = 0
i = 0
do
s = s + a[i] * b[i]
i = i + 1
loop until i = n
Jump Statements
The jump statement, when executed, transfers control unconditionally. There are ve such statements in mikroBasic
PRO for PIC32:
- break
- continue
- exit
- goto
- gosub
Break and Continue Statements
Break Statement
Sometimes, you might need to stop the loop from within its body. Use the break statement within loops to pass control
to the rst statement following the innermost loop (for, while, or do).
For example:
Lcd_Out(1, 1, “No card inserted”)
‘ Wait for CF card to be plugged; refresh every second
while true
if Cf_Detect() = 1 then
break