Release 10.1A: OpenEdge Development:
Progress 4GL Handbook

> ## RETURN statement and RETURN-VALUE

> First you’ll look at a small, but important, procedure topic. Whenever a procedure, whether internal or external, terminates and returns control to its caller, it returns a value to the caller. You can place a `RETURN` statement at the end of your procedure to make this explicit, and to specify the value to return to the caller:

>     RETURN [ return-value ].

> The `return-value` must be a character value, either a literal or an expression. The caller (calling procedure) can access this `return-value` using the built-in `RETURN-VALUE` function, such as in this example:

>     RUN subproc (INPUT cParam).
>     IF RETURN-VALUE = . . . THEN
>          .
>          .
>          .

> If the called procedure doesn’t 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-value`s 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. You’ll learn more about this option in Chapter 16, " Updating Your Database and Writing Triggers."

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095