System.Exit

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

procedure Exit;

Properties

Type Visibility Source Unit Parent
procedure public System.pas System System

Description

Exits from the current procedure.

In Object Pascal, the Exit procedure immediately passes control away from the current procedure. If the current procedure is the main program, Exit causes the program to terminate.

Exit causes the calling procedure to continue with the statement after the point at which the procedure was called.

Note: Exit passes control away from the current procedure, not merely the current block. However, Exit does not violate the flow of control dictated by a try..finally construct; if Exit is called inside the try clause, the finally clause is still executed.

Beginning with Object Pascal 2009, Exit can take a parameter specifying a result. The parameter must be of the same type as the result of the function. For example:


function DoSomething(aInteger: integer): string;
begin
  if aInteger < 0 then
  begin
    Exit('Negative');
  end;
  Result := 'Positive';
end;


See Also

Code Examples