SmartPascal
Exit
Procedure
Exit abruptly from a function or procedure System unit
 procedure Exit ;
Description
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
 
Example code : Exit a proc when a user cancels data entry
begin
  // Ask the user for their name
  ShowMessage('Name = '+AskForName);
end;

// Ask the user for first and second names
function TForm1.AskForName: string;
var
  firstName, secondName : string;
begin
  Result := 'Lazy person';
  repeat
    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;
end;
Show full unit code
   If the user cancels from the first or second name dialogs, the ShowMessage dialog gives:
  
   Name = Lazy person