Exit Procedure
Call the Exit
procedure to return immediately from
a function or procedure. If you call Exit
from
within a try-finally
block, the
finally
parts runs before the subroutine
returns.
The Exit
procedure is built into the compiler and
is not a real procedure. If you call Exit
outside
of a subroutine or method, Delphi exits the application.
// Compute the number of iterations at the point (X, Y).
// Stop at MaxIterations, which is a crude approximation of infinity.
// This function is used in the BeginThread example.
function ComputeIterations(X, Y: Double): Integer;
const
Threshold = 4.0;
var
XNew, YNew: Double;
XC, YC: Double;
begin
XC := X;
YC := Y;
for Result := 0 to MaxIterations-1 do
begin
XNew := X * X - Y * Y + XC;
YNew := 2 * X * Y + YC;
if (XNew * XNew + YNew * YNew) > Threshold then
Exit;
X := XNew;
Y := YNew;
end;
Result := MaxIterations;
end;