Mikroelektronika MIKROE-724 データシート

ページ / 726
232
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Exit Statement
The 
exit
 statement allows you to break out of a routine (function or procedure). It passes the control to the first 
statement following the routine call.
Here is a simple example:
sub procedure Proc1()
dim error as byte
  ... ‘ we’re doing something here
  if error = TRUE then
    exit
  end if
  ... ‘ some code, which won’t be executed if error is true
end sub
Note: If breaking out of a function, return value will be the value of the local variable 
result
 at the moment of exit. 
Return Statement
The return statement causes execution to leave the current subroutine and resume at the point in the code immediately 
after where the subroutine was called. It’s mainly intended to be used with gosub statement. 
Return statement suffers from the same sort of readability problems as the GOTO statement and like goto, the use of 
return statement is generally discouraged.
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 specified. 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 specified by 
label_name
. The 
goto
 line can come before or 
after the label.