procedure Exit;
or
procedure Exit (program);
or
procedure Exit (Identifier);
Exit
without an argument leaves the currently executed
procedure or function. Note: If Exit
is called within the
main program, it will be terminated instantly.
Exit
with an argument that is program
or the name of
the current program, terminates the program, and is equivalent to
Halt
.
Exit
with an argument that is the name of the current or an
encompassing routine leaves that routine.
Exit
is a UCSD Pascal extension. Borland Pascal only allows
it without an argument.
program ExitDemo; procedure Foo (Bar: Integer); var Baz, Fac: Integer; begin if Bar < 1 then Exit; { Exit `Foo' } Fac := 1; for Baz := 1 to Bar do begin Fac := Fac * Baz; if Fac >= Bar then Exit; { Exit `Foo' } WriteLn (Bar,' is greater than ', Baz, '!, which is equal to ', Fac) end end; begin Foo (-1); Foo (789); Exit; { Terminates program } Foo (987654321) { This is not executed anymore } end.