Return control from a subroutine

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS


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.


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.

See also

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
    val         ,i4
    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)
    val = val + 7
    return                      ;Returns to Point A