Exit abruptly from a function or procedure System unit
 procedure Exit ;
The Exit procedure abruptly terminates the current function or procedure.
If exiting a function, then Result contains the last set value.
Warning : use with caution - jumping is a concept at odds with structured coding - it makes code maintenance difficult.
Related commands
Break Forces a jump out of a single loop
Continue Forces a jump to the next iteration of a loop
Goto Forces a jump to a label, regardless of nesting
Halt Terminates the program with an optional dialog
RunError Terminates the program with an error dialog
 Author links

 Buy Website Traffic at

 Buy Proxies at
 Download this web site as a Windows program.

Example code : Exit a proc when a user cancels data entry
  // Ask the user for their name
  ShowMessage('Name = '+AskForName);

// Ask the user for first and second names
function TForm1.AskForName: string;
  firstName, secondName : string;
  Result := 'Lazy person';
    if not InputQuery('Test program', 'First name :', firstName)
    then Exit;
    if not InputQuery('Test program', 'Second name :', secondName)
    then Exit;
  until (firstName <> '') or (secondName <> '');

  Result := firstName + ' ' + secondName;
Show full unit code
   If the user cancels from the first or second name dialogs, the ShowMessage dialog gives:
   Name = Lazy person
Delphi Programming Neil Moffatt 2002 - 2020. All rights reserved.  |  Home Page