RETURN

Return control from a subroutine

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
RETURN

The RETURN statement returns control to the statement that follows the call to the most recently executed subroutine. RETURN is normally used to return from internal subroutines, although it can be used to return from external subroutines (see note below).

In traditional Synergy, if RETURN is executed with no outstanding CALL or XCALL present, a “Return with no CALL or XCALL” error (NOCALL) is generated.

Note

Using a RETURN statement without a corresponding CALL in a subroutine is deprecated. We recommend that you use the XRETURN statement, instead of RETURN, to return from an external subroutine.

In Synergy .NET, regardless of whether or not a CALL has occurred, a RETURN will XRETURN if there are no more items on the call stack.

Writing and calling subroutines and functions for more information on internal subroutines

In the following example, RETURN is used both to return from an internal subroutine and from an external subroutine.

subroutine mysub
record
    val         ,i4
proc
    val = 1
    call do_val                 ;Call to internal subroutine
    val = val x 2               ;Point A
    return                      ;Returns from subroutine back to calling    
                                ; program (equivalent of xreturn)
do_val,
    val = val + 7
    return                      ;Returns to Point A
endsubroutine