There are two ways to leave an ESL program programmatically.
Specify an exit statement to return control to the operating system.
Specify a change to program statement to transfer control to another ESL program within the complete ESL interface. (See Transferring to Another Program.)
The exit action statement ends the current program. The exit action statement, like other action statements, can be specified in a response definition or in an action routine definition.
Specify the exit statement as the final statement in the set of action statements in the response definition for terminating the program. Statements following the exit statement will be ignored. For example:
response to ExitKey
send ShutdownMessage to Audit
exit
In this example, if exit were specified before the send statement, ESL would terminate before executing the send statement, and the Audit program would not receive its logoff code.
You can optionally specify an integer value as the exit code in the exit statement; this value is returned to the operating system when ESL terminates; for example:
response to ExitKey
send ShutdownMessage to Audit
exit 32
This value provides information about the ESL session and might be used by the operating system to condition the execution of other programs.
If you want to save the currently executing program as a new program with the current state of its objects and local variables, you can use the save program as statement before the exit statement. (See Saving a Program in Progress.) Note that the save program as statement can be used in an action routine but not in a subroutine.