Defining subroutines
Define subroutines to allow chunks of code to be reused
from different parts of the main program. Subroutines are called by
the CALL SUB
command.
You define subroutines by using the SUBROUTINE
statement,
which must be coded at the end of the program stream from which they
are being called. SUBROUTINE
statements must
not be contained within INCLUDE
statements,
but subroutines can contain INCLUDE
statements.
A subroutine must start with SUBROUTINE
and
end with RETURN
, but a RETURN
statement
is assumed when the next SUBROUTINE
statement
or the end of the stream of code is encountered. You can use IF
-THEN
-ELSE
to
issue a RETURN
statement to conditionally
exit a subroutine.