User manual

230
mikoBasic PRO for PIC32
MikroElektronika
Here is a simple example:
sub procedure Proc1()
dim error as byte
... ‘ we’re doing something here
if error = TRUE then
return
end if
... ‘ some code, which won’t be executed if error is true
end sub
Note: Return statements performs the same as exit statement except in functions. If breaking out of a function with
return statement, return value will not be specied. In such cases exit statement should be used.
Goto Statement
Use the goto statement to unconditionally jump to a local label — for more information, refer to Labels. The syntax of
the goto statement is:
goto label_name
This will transfer control to the location of a local label specied by label_name. The goto line can come before or
after the label.
Label and goto statement must belong to the same block. Hence it is not possible to jump into or out of a procedure
or function.
You can use goto to break out from any level of nested control structures. Never jump into a loop or other structured
statement, since this can have unpredictable effects.
The use of goto statement is generally discouraged as practically every algorithm can be realized without it, resulting
in legible structured programs. One possible application of the goto statement is breaking out from deeply nested
control structures:
for i = 0 to n
for j = 0 to m
...
if disaster
goto Error
end if
...
next j
next i
.
.
.
Error: ‘ error handling code