Typically, the place you programatically set the value for a RETURN or RETURN ERROR statement in an error object. The ReturnValue property, when set by the AVM, contains the error string from a RETURN ERROR statement.
If you were not using an error object, these values would usually be accessed through the RETURN-VALUE function. You would also find the values in the RETURN-VALUE function when:
A program throws an AppError and the caller suppresses the error with the NO-ERROR option.
The AVM creates an AppError object when encountering a RETURN ERROR ErrorString statement. ErrorString is used to populate the ReturnValue property.