3.9 Try..except
Try..Except used if there have possibility ERROR.
Sintax :
<code>
try
<statements_list1>;
except
<statements_list2>;
end;
</code>
operation: the first program will execute one or more statements under try. if not error, program will execute statements until <strong>end;</strong> statements. if any error under <strong>try</strong> statement program will jump and execute the statement below <strong>except</strong>.
attention ! try..except will work if option <strong>stop</strong> on <strong>Delphi Exception</strong> listed on page language exceptions in the menu tools-->debugger Options is not check.
examples 1 try..except
<code>
try
x:=i/j;
except
on EZeroDivide do HandleZeroDivide;
end;
</code>
<hr/>
examples 2 try..except
<hr/>
<code>
try
. . .
except
on EzeroDivide do HandleZeroDivide;
on EOverflow do HandleOverflow;
onEMathError do HAndleMathError;
end;
</code>
<hr/>
examples 3 try..except
<hr/>
<code>
try
. . .
except
on EzeroDivide do HandleZeroDivide;
on EOverflow do HandleOverflow;
onEMathError do HAndleMathError;
else
HandleAllOthers;
end;
</code>
No comments:
Post a Comment