RETURN statement
- Last Updated: February 11, 2026
- 3 minute read
- OpenEdge
- Version 13.0
- Documentation
Leaves the local or remote procedure, user-defined function,
ON trigger, method of a class, class constructor or destructor, or
property accessor, and returns to the caller. If there is no caller, returns to the
Procedure Editor or Progress Developer Studio for OpenEdge tool.
Syntax
|
- return-value
-
This has different behavior depending on whether a value can be returned from the current context. From contexts that don’t return a value, this is used to set
RETURN-VALUE.For a procedure or
ONtrigger block, the value is used to setRETURN-VALUE:- If return-value is specified, it must be a CHARACTER expression.
- If return-value is not
specified,
RETURN-VALUEis set to the empty string (""). - To retrieve the return-value,
access the
RETURN-VALUEfunction from the caller.
For a user-defined function, non-VOID method, or property accessor:- Return-value must be specified.
- Return-value must be an expression whose data type matches the return type of the function, method, or property; data type matching between the expression and return type follows the data type widening rules for an expression passed to an OUTPUT parameter (see the Parameter passing syntax entry for more information).
- To retrieve the return-value from the caller, simply reference the function or method call in an expression.
For a VOID method, you cannot set a return-value.
- ERROR
- Causes an
ERRORcondition in the calling block.You cannot use the
ERRORoption in a user-interface trigger block to raiseERRORoutside of the trigger block.RETURN ERRORin a user-defined function does not raiseERRORin the caller. Instead, it sets the target variable of the function to the Unknown value (?). See ABL Error Handling for more information. - error-return-value
- Any CHARACTER expression.
To retrieve the return value in the caller, catch the
Progress.Lang.AppErrorusing aCATCHstatement and obtain theReturnValueproperty of theAppError. Alternatively, the caller can access theRETURN-VALUEfunction.If you do not specify either error-return-value or error-object-expression, both the
RETURN-VALUEfunction as well as theAppErrorReturnValueproperty is set to the empty string(""). - error-object-expression
-
An expression that resolves to a specific error object. It must be an object derived from
Progress.Lang.ProErroror an object of a class that implementsProgress.Lang.Error. The compiler generates an error if these rules are not met. Note that the only error object you can instantiate directly is aProgress.Lang.AppErrorobject or a subclass.RETURN ERRORerror-object-expression immediately returns to the caller before throwing the error object. - NO-APPLY
- Suppresses the default behavior for the current user-interface event.
You thus can use the
NO-APPLYoption in a user-interface trigger block to suppress that behavior. For example, the default behavior for a character code key press in a fill-in field is to echo the character in the field. If you executeRETURN NO-APPLYin a trigger, this behavior is not performed. Also,NO-APPLYreturns without setting a return-value or error object.
Examples
The following code demonstrates using RETURN in a
user-defined function.
|
Output:
|
The following code illustrates using RETURN ERROR in a
user-defined function.
|
Output:
|
The following code demonstrates using RETURN ERROR with
an error object.
|
Output:
|
Notes
- The
RETURN-VALUEfunction provides the value set by the most recently executedRETURNstatement. - If a procedure executing the
RETURNstatement is called asynchronously, the client can access the return-value andERRORcondition in the associated event procedure or method. - Class-based error objects can be thrown from an application server and
handled by a
CATCHblock on an ABL client. To be throwable from an application server to an ABL client, user-defined error classes must be defined on both the server and client sides, and the classes must be defined asSERIALIZABLE. For the full list of restrictions on class-based objects that are passed between application server and client, see the Parameter passing syntax entry. For more information on error handling in general, see ABL Error Handling. - Class-based error objects can also be thrown from an application server
to a client for an asynchronous request. Using
RETURN ERRORis one way to do this. In this case, the error object is returned to the client via theERROR-OBJECTattribute of the Asynchronous request object handle.
See also
CONSTRUCTOR statement, DEFINE PROPERTY statement, ERROR-OBJECT attribute, FUNCTION statement, METHOD statement, ON ENDKEY phrase, ON ERROR phrase, ON QUIT phrase, ON STOP phrase, RETURN-VALUE function, UNDO statement