User manual

230
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Here is an example of calculating scalar product of two vectors, using the while statement:
s = 0
i = 0
while i < n
s = s + a[i] * b[i]
i = i + 1
wend
Probably the easiest way to create an endless loop is to use the statement:
while TRUE
‘ ...
wend
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