RETURN statement and RETURN-VALUE
- Last Updated: August 3, 2023
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
RETURN statement at the end of your
procedure to make this explicit, and to specify the value to return to the
caller:
|
RETURN-VALUE
function, such as in this example:
|
If the called procedure does not return a value, then the value returned is either the
empty string (“”) or, if an earlier procedure RUN
statement in the same call stack returned a value, then that value is returned.
The RETURN statement is optional in procedures. Because an earlier
RETURN-VALUE is passed back up through the call stack if there’s no
explicit RETURN statement to erase it, it is good practice to have the
statement RETURN “” at the end of every procedure to clear any old
value, unless your application needs to pass a RETURN-VALUE back
through multiple levels of a procedure call.
In addition, you can return to the calling procedure from multiple places in the called
procedure by using multiple RETURN statements in different places. You
could use this technique, for example, to return one return-value
representing success (possibly the empty string) and other
return-values from different places in the procedure code to
indicate an error of some kind.
You can also use RETURN ERROR from a procedure to signal an error.