End of Statement, Program or Application

This document covers the following topics:

End of Statement

To explicitly mark the end of a statement, you can place a semicolon (;) between the statement and the next statement. This can be used to make the program structure clearer, but is not required.

End of Program

The END statement is used to mark the end of a Natural program, function, subprogram, external subroutine or helproutine.

Every one of these objects must contain an END statement as the last statement.

Every object may contain only one END statement.

End of Application

Ending the Execution of an Application by a STOP Statement

The STOP statement is used to terminate the execution of a Natural application. A STOP statement executed anywhere within an application immediately stops the execution of the entire application.

Ending the Execution of an Application by a TERMINATE Statement

The TERMINATE statement stops the execution of the Natural application and also ends the Natural session.

Interrupting a Running Natural Application

During the development of a Natural application and in test situations, the user should be able to interrupt a running Natural application that does not respond anymore, for example, due to an endless loop. As the Natural session should not need to be killed, the running Natural application can be interrupted via the typical system interrupt key combination (for example, CTRL+BREAK for Windows, CTRL+C for UNIX and OpenVMS). The Natural error NAT1016 is raised and the runtime error processing is activated. The error can be handled by an ON ERROR processing.

In a production environment, this feature will typically need to be disabled, because the application may not be able to recover from a user interrupt at an arbitrary program location.

The Natural profile parameter RTINT determines whether interrupts are allowed. By default, interrupts are not allowed.

If this parameter is set to ON, a running Natural application may be interrupted with the interrupt key combination of the operating system (for example, for Windows: CTRL+BREAK; for UNIX: typically CTRL+C, but can be reconfigured using the stty command; for OpenVMS: CTRL+C).

Natural catches this interrupt request and then offers the user the following possibilities:

  • Perform standard error processing by raising a NAT1016 error.

  • Continue application processing (cancel interrupt).

The choice is shown in a window that is opened after catching the interrupt signal.

The Natural application will only be interruptible if the Natural application or Natural Studio that started the application has the input focus.