<div dir='auto'>delphi apparently functions the same if I've read the docs right. something about returning control to the exception handler BEFORE your program gets control back.<br><br><div data-smartmail="gmail_signature">--<br>Alexander Grotewohl<br>http://dcclost.com</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Jun 23, 2019 3:08 AM, Dennis <dec12@avidsoft.com.hk> wrote:<br type="attribution" /><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Using fpc 3.0.4, Lazarus 2.0, the following simple program</p>
<p dir="ltr">program tryfinally;</p>
<p dir="ltr">begin<br>
try<br>
Writeln('before finally');<br>
finally<br>
Writeln('inside finally. Before Exit');<br>
exit; //<----why isn't it executed?<br>
end;<br>
Writeln('after try finally block');</p>
<p dir="ltr">end.<br></p>
<p dir="ltr">gives<br></p>
<p dir="ltr">P:\RAM64>tryfinally.exe<br>
before finally<br>
inside finally. Before Exit<br>
after try finally block<br><br></p>
<p dir="ltr">I have tried putting the try finally block inside a procedure, the same <br>
happened.<br>
program tryfinally;</p>
<p dir="ltr">procedure Test;<br>
begin<br>
try<br>
Writeln('before finally');<br>
finally<br>
Writeln('inside finally. Before Exit');<br>
exit;<br>
end;<br>
Writeln('after try finally block');<br>
end;</p>
<p dir="ltr">begin<br>
Test;</p>
<p dir="ltr">end.</p>
<p dir="ltr">Dennis<br>
_______________________________________________<br>
fpc-pascal maillist - fpc-pascal@lists.freepascal.org<br>
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal<br>
</p>
</blockquote></div><br></div>