Description: This statement sets the return value for the module in which it is executed.
Returns: Nothing
Usage: Script or Steady State
Format: Return(X)
Parameters: X { varies } { required } { no default: }
Any variable, expression, constant or object value. It can be of any type.
Comments: If a Return statement appears anywhere in the code of a launched module (i.e. one that is executed inside of a script or using the Launch statement), even if that portion of the code is not executed, the module will be considered to be a sub-routine, and will block execution of all other modules in the same thread while it is executing. Execution of the Return statement in a sub-routine results in the module being slain without having to use the Slay statement.
If the Return statement is used in a called module (i.e. one that appears as a statement in a state), execution of the Return statement will not stop the execution of the module.
The return value for the module is set equal to X, and is the same type as the expected value of the module call. The type of the return value is set every time Return is executed, which allows modules to return different types of values during execution if they are called (rather than launched).
This statement may appear both inside or outside of a script, and like other statements that may be called from a state, if multiple calls are active simultaneously in a module, the return value will be invalid.
Example:
Main [ { State in Module Graphics }
ZText(500, 100, test , 15, 0);
]
< { Sub-module of Module Graphics }
Test
State1
[
Return("example of return function");
]
>
This sets the return value of the module Test to "example of return function" which is displayed by the ZText statement in state Main of the Graphics module.
See Also: