Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
Goto Statement
Use the 
goto
statement to unconditionally jump to a local label — for more informa-
tion, refer to Labels. Syntax of 
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.
The label declaration, marked statement 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.
Use of 
goto
statement is generally discouraged as practically every algorithm can
be realized without it, resulting in legible structured programs. One possible appli-
cation of goto statement is breaking out from deeply nested control structures:
for (...) do
begin
for (...) do
begin
...
if (disaster) then goto Error;
...
end;
end;
.
.
.
Error: // error handling code
174
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroPASCAL PRO for AVR
CHAPTER 5