Description |
The Halt procedure forces an abrupt termination of the current application.
Warning : resources cannot be guaranteed to be freed when calling halt.
Optionally, the ExitCode variable may be set by passing an ExitValue. This code is returned to the application invoker as the return code from the application.
If ErrorAddr has been assigned a value, when Halt is called, a dialog is displayed showing the ErrorAddr and ExitCode values.
After Halt executes, the finalization section of the unit is executed before the program actually terminates.
|
|
Notes |
Warning : use only in exceptional circumstances.
|
|
Related commands |
Break |
|
Forces a jump out of a single loop |
Continue |
|
Forces a jump to the next iteration of a loop |
Exit |
|
Exit abruptly from a function or procedure |
ExitCode |
|
Sets the return code when an application terminates |
Goto |
|
Forces a jump to a label, regardless of nesting |
RunError |
|
Terminates the program with an error dialog |
Abort |
|
Aborts the current processing with a silent exception |
|
|
|
|
Example code : Halt a program with an error dialog |
// Full Unit code. // ----------------------------------------------------------- // You must store this code in a unit called Unit1 with a form // called Form1 that has an OnCreate event called FormCreate. unit Unit1; interface uses // The System unit does not need to be defined Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); var
i : Integer;
begin // Set up an error address so that halt shows a termination dialog
ErrorAddr := Addr(i);
// Stop the program with exit code 4
Halt(4);
// The following will not be executed
ShowMessage('We do not get this far');
end; end.
|
Hide full unit code |
The program terminates without running the ShowMessage statement. An error dialog is displayed:
Runtime error 4 at 0069FC94
|
|