EXIT

EXIT leaves a program unconditionally.

Read syntax diagramSkip visual syntax diagram EXIT expression ;

Optionally, EXIT returns a character string to the caller. The program is stopped immediately, even if an internal routine is currently being run. If no internal routine is active, RETURN (see RETURN) and EXIT are identical in their effect on the program that is being run.

If you specify expression, it is evaluated and the string resulting from the evaluation is passed back to the caller when the program stops. For example:

j=3
Exit j*4
/* Would exit with the string '12' */

If you do not specify expression, no data is passed back to the caller. If the program was called as an external function, this is detected as an error; either immediately (if RETURN was used), or on return to the caller (if EXIT was used).

Running off the end of the program is always equivalent to the instruction EXIT, in that it stops the whole program and returns no result string.

Note: If the program was called through a command interface, an attempt is made to convert the returned value to a return code acceptable by the underlying operating system. If the conversion fails, it is deemed to be unsuccessful because of the underlying operating system and thus is not subject to trapping with SIGNAL ON SYNTAX. The returned string must be a whole number whose value fits in a general register (that is, must be in the range -2**31 through 2**31-1).