Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
RETURN
◄Up► ◄Contents► ◄Index► ◄Back►
─────RETURN ────────────────────────────────────────────────────────────────
Action
Returns control to the calling program unit.
Syntax
RETURN [ordinal]
Parameter Description
ordinal An integer constant specifying the position
of an alternate-return label.
Remarks
RETURN terminates execution of the enclosing subroutine or
function. END in a function or subroutine has the same effect as
RETURN.
If the actual arguments of a CALL contain alternate-return
specifiers, RETURN can return control to a specific statement.
Alternate-returns work only with subroutines. They cannot appear
in a function.
A RETURN statement in the main program is treated as a STOP
statement with no <message> parameter.
See Also: ◄CALL►
◄STOP►
Examples
C This subroutine loops until you type "Y":
SUBROUTINE Loop
CHARACTER in
10 READ (*, '(A)') in
IF (in .EQ. 'Y') RETURN
GOTO 10
C RETURN implied by the following statement:
END
The following example demonstrates the alternate-return feature:
01 CALL AltRet (i, *10, j, *20, *30)
WRITE (*, *) 'normal return'
GOTO 40
10 WRITE (*, *) 'I = 10'
GOTO 40
20 WRITE (*, *) 'I = 20'
GOTO 40
30 WRITE (*, *) 'I = 30'
40 CONTINUE
.
.
.
SUBROUTINE AltRet (i, *, j, *, *)
IF (i .EQ. 10) RETURN 1
IF (i .EQ. 20) RETURN 2
IF (i .EQ. 30) RETURN 3
RETURN
In this example, RETURN 1 specifies the list's first
alternate-return label, which is a symbol for the actual argument
*10 in the CALL statement. RETURN 2 specifies the second
alternate-return label, and RETURN 3 specifies the third
alternate-return label.
-♦-