Syntax
RETURN [ expression ] | [ instance AsA interface ]
Parameters
expression
When used in a typed method, the value to return. The type of this expression must match the type of the current method.
instance
An instance of a Serializable class (that is, a class that implements a Serialization).
interface
The name of the Serialization that is implemented by the Serializable class referred to in the instance.
Description
The Return logic command returns control to the calling method of the current method and optionally a value as defined by the method variable type.
The method variable is one specified with the same name as its owning method. If a method variable is not defined for its owning method, the Return logic command can only be used within the logic of the method without expression.
The value returned can be that of the method variable, or that of the expression specified. If no value has been assigned to the method variable, and no expression is specified by the Return logic command, a null or empty value is returned.
If an explicit Return logic statement is not executed at the end of the logic execution path of a method with a defined method variable, an implicit Return logic statement is executed instead.
A special version of the Return logic command is used in the Respond() method of a Messenger class.
The Respond() method is defined with a ReturnType of String. The String return value contains the XML message stream. To return the XML message you must use the Return logic command to return a Serializable class instance that is cast to a Serialization through the “AsA” command option. The returned instance is implicitly converted to a string value by serializing the instance according to the interface definition. The AsA Interface parameter is required to specify the interface to be used to serialize the class to XML. The use of “AsA” clause is mandatory even if the serializable class implements only one interface.
Restrictions
Errors occur with use of the Return logic command if any of the following conditions apply:
The primitive type of the returned expression does not match the type of the method variable.
The method type is "void" but a return value is specified.
Examples
Example 1
Return A * 123 + C
Example 2
In this example, the MyMethod method has the following logic:
MyMethod := (A * 123) + C Return : Returns the value of the MyMethod method variable
Example 3
Return
Example 4
The following is an example of the Return logic command in Respond() of a Messenger class. This takes a populated instance of a Serializable class called aResponseObject, and then casts it to the IResponse interface. The action of returning a Serializable object cast to an interface results in this object being serialized to an XML message and included in the Messenger response.
Return aResponseObject AsA IResponse