Marks the end of a program unit or procedure.
Syntax
- keyword
is one of the keywords BLOCK DATA, FUNCTION, MODULE, PROGRAM, or SUBROUTINE. When the END statement is used for an internal procedure or module
procedure, the FUNCTION or SUBROUTINE keyword is required.
- name
is the name given to the program unit. If name is specified, keyword must also be specified.
Description
The END statement is the last statement of a program unit
(that is, a main program, function, subroutine, module, or block
data subprogram), an internal procedure, or a module procedure. It
is the only statement that is required within a program unit.
Examples
The following example illustrates the use of the END statement to indicate the end of a main program.
Notice that, even though the main program unit is given a name,
the END PROGRAM statement does not require it:
PROGRAM main_prog ... END PROGRAM |
In the next example, the END statement marks the end of an internal function
and must therefore specify the keyword FUNCTION. However, it is not required that the name, get_args, be also specified:
FUNCTION get_args (arg1, arg2) ... END FUNCTION get_args |
The following example uses the END statement to indicate the end of a block data
subprogram. Because the END statement specifies the program unit name, it
must also specify the keyword BLOCK DATA:
BLOCK DATA main_data ... END BLOCK DATA main_data |
Related statements
BLOCK DATA, FUNCTION, MODULE, PROGRAM, and SUBROUTINE
Related concepts
For information about program units, see “Program
units”.