For more information on remote procedures, see OpenEdge Application Server: Developing AppServer Applications.
RETURNreturn-valueERROR return-value error-object-expressionNO-APPLY
Without the ERROR condition — In a procedure or trigger block, the optional return-value must be a CHARACTER expression. If you do not specify return-value in a procedure or trigger block, return-value is returned as the empty string (""). In a VOID method, you cannot set a return-value. In a user-defined function or in a method of a class that returns a value (non-VOID), return-value must be specified and must be an expression whose data type matches the return type of the function or method; 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 reference entry for more information).
With the ERROR condition — In a method of a class (VOID or non-VOID), a constructor, a property accessor, a user-defined function, a procedure, or a database trigger block, the optional return-value must be a CHARACTER expression. If you do not specify either return-value or error-object-expression (see the ERROR option), return-value is returned as the empty string ("").For more information on how the caller can access return-value in each case, see the ERROR option.
Any statement that invokes the NEW function (classes) to instantiate a class (invoking the specified constructor and all other constructors for the class hierarchy)You can use the ERROR option in a procedure, database trigger block, class-based method, constructor, property accessor method, or user-defined function. However, you cannot use the ERROR option in a user-interface trigger block to raise ERROR outside of the trigger block. Any values that are set for OUTPUT or INPUT-OUTPUT parameters before the RETURN ERROR executes are not returned to the caller.If return-value is specified, the ABL Virtual Machine (AVM) automatically generates a Progress.Lang.AppError that the caller can obtain using a CATCH statement and obtain return-value from the ReturnValue property of the AppError. If no return-value or error-object-expression is specified, the AVM also generates an AppError with its ReturnValue property set to the empty string (""). The following table shows how to access return-value in the caller in various cases:
The return-value is specified without the ERROR option in a procedure or trigger block. The return-value is specified for a non-VOID method or user-defined function without the ERROR option. The return-value is specified with the ERROR option. Access the RETURN-VALUE function, or CATCH the Progress.Lang.AppError object automatically created by the AVM and check the ReturnValue property of the AppError object. The error-object-expression is specified If error-object-expression is a Progress.Lang.AppError, CATCH the specified error object and access its ReturnValue property, or access the RETURN-VALUE function.An expression that resolves to a specific error object. It must be an object derived from Progress.Lang.ProError (you can only THROW error objects) or an object of a class that implements Progress.Lang.Error. It is a compile-time error to THROW an object that is not derived from Progress.Lang.ProError or Progress.Lang.Error. Note that the only error object that you can instantiate directly is a Progress.Lang.AppError object or a subclass.
Note: RETURN ERROR error-object-expression immediately returns to the caller before throwing the error object. Unlike a direct THROW, it ignores any CATCH blocks or ON ERROR directives in effect at the time of the RETURN.If you do not specify any options for the RETURN statement in a procedure or trigger block, return-value is returned as the empty string (""). In a VOID method, you cannot specify any options except for the ERROR options, and RETURN without ERROR options returns without setting a return-value or error object.The r-fact.p procedure is called recursively because (n factorial) is n * ((n - 1) factorial). The r-fact.p procedure first checks that the input value is valid. If the value is invalid, it returns a message to the caller. Note that r-return.p checks the ReturnValue property immediately after running r-fact.p. If a message is returned, r-return.p displays that message.The procedure r-return.p accepts an integer as input and then runs r-fact.p to calculate the factorial of that integer. The factorial of a number is the result of multiplying together all of the integers less than or equal to that number (for example: 3 factorial is 3 * 2 * 1 = 6). The r-fact.p procedure is called recursively because n factorial is n * (n -1) factorial.
If a procedure executing the RETURN statement is called asynchronously, the client can access the return-value and ERROR condition in the associated event procedure. For more information on event procedures, see OpenEdge Application Server: Developing AppServer Applications.
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |