From Appmethod Libraries
Jump to: navigation, search

Object Pascal

procedure Exit;


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


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;
  if aInteger < 0 then
  Result := 'Positive';

See Also

Code Examples