The exit procedure terminates the program or the function or procedure in which it is used, and optionally may return a value to the caller.
If used in a function then the exit procedure terminates the function. If used in a function named f then exit(e) is equivalent to:
f := e; exit
If used in a procedure then exit terminates the procedure. If used in a procedure then exit(x) is invalid since you can not return a value from a procedure.
If used in the main program then exit terminates the program. If used in the main program then exit(e) is equivalent to:
ExitCode := e; exit
(i.e. the program is terminated with e as the exit code).
The exit procedure's only paramter is an expression. If supplied this parameter is the value to be returned by the program or function or procedure.
Operating Systems: All Standard Pascal: No