13.1.1 SUB Subprograms
A SUB subprogram is a program module that can be sep-
arately compiled and that cannot return a value. A SUB
subprogram is delimited by the SUB and END SUB state-
ments. You may use the EXTERNAL statement to explicitly
declare the SUB subprogram.
The END SUB statement does the following:
The EXIT SUB statement transfers control to the statement
lexically following the statement that invoked the subpro-
gram. It is equivalent to an unconditional branch to an END
SUB statement.
The following SUB subprogram sorts two integers. If this
SUB statement is invoked with actual parameter values
that are already in sorted order, the EXIT SUB statement is
executed and control returns to the calling program.
SUB sort_out (INTEGER X, INTEGER Y)
DECLARE INTEGER temp
IF X > Y
THEN
temp = X
X = Y
Y = temp
ELSE
EXIT SUB
END IF
END SUB