paxCompiler/help/pascal_except.htm
Dalibor Marković 9d0de424e8
Init
Signed-off-by: Dalibor Marković <dalibor31@gmail.com>
2024-07-06 22:28:12 +02:00

105 lines
2.5 KiB
HTML

<html>
<head>
<link rel=stylesheet type="text/css" href="styles.css">
</head>
<body>
<H2>
Pascal samples. Exception handling.
</H2>
<hr>
<H4>
Example 1
</H4>
<blockquote>
<pre>
<font color="blue"><b>uses</b></font>
SysUtils;
<font color="blue"><b>procedure</b></font> ErrorProc;
<font color="blue"><b>var</b></font>
I: Integer;
<font color="blue"><b>begin</b></font>
I := 0;
I := I div I;
<font color="blue"><b>end</b></font>;
<font color="blue"><b>procedure</b></font> TestExcept;
<font color="blue"><b>var</b></font>
S: <font color="blue"><b>String</b></font>;
I: Integer;
<font color="blue"><b>begin</b></font>
S := <font color="Red">'abc'</font>;
<font color="blue"><b>try</b></font>
ErrorProc;
<font color="blue"><b>except</b></font>
<font color="blue"><b>on</b></font> E:EDivByZero <font color="blue"><b>do</b></font>
<font color="blue"><b>begin</b></font>
writeln(S);
S := E.Message;
writeln(S);
<font color="blue"><b>end</b></font>;
<font color="blue"><b>else</b></font>
<font color="blue"><b>begin</b></font>
writeln(456);
<font color="blue"><b>end</b></font>;
<font color="blue"><b>end</b></font>;
<font color="blue"><b>end</b></font>;
<font color="blue"><b>begin</b></font>
TestExcept;
writeln(<font color="Red">'ok'</font>);
<font color="blue"><b>end</b></font>.
</pre>
</blockquote>
<H4>
Example 2
</H4>
<blockquote>
<pre>
<font color="blue"><b>uses</b></font>
SysUtils;
<font color="blue"><b>procedure</b></font> ErrorProc;
<font color="blue"><b>var</b></font>
I: Integer;
<font color="blue"><b>begin</b></font>
I := 0;
I := I div I;
<font color="blue"><b>end</b></font>;
<font color="blue"><b>procedure</b></font> TestFinally;
<font color="blue"><b>var</b></font>
S: <font color="blue"><b>String</b></font>;
I: Integer;
<font color="blue"><b>begin</b></font>
S := <font color="Red">'abc'</font>;
<font color="blue"><b>try</b></font>
ErrorProc;
<font color="blue"><b>finally</b></font>
writeln(S);
<font color="blue"><b>end</b></font>;
writeln(<font color="Red">'not executed'</font>);
<font color="blue"><b>end</b></font>;
<font color="blue"><b>begin</b></font>
<font color="blue"><b>try</b></font>
TestFinally;
<font color="blue"><b>except</b></font>
writeln(<font color="Red">'ok'</font>);
<font color="blue"><b>end</b></font>;
<font color="blue"><b>end</b></font>.
</pre>
</blockquote>
<p>
<HR>
<font size = 1 color ="gray">
Copyright &copy; 2006-2009
VIRT Laboratory. All rights reserved.
</font>
</body>
</html>