|
|||||
|
|||||
action |
return |
Syntax
return (expression)?
To return a value from a function, use the return
keyword followed by an expression of the same type as the function return type. Executing the return
keyword exits the function, so code after return
will not be executed.
If the function contains an always
block, the code in the always block will be executed after the return statement is executed and before the function terminates. The return value of the function is determined when return
is executed, and cannot be changed in the always block. (You can place the return
statement in the always block, in which case return
will exit the function when it is executed, and the rest of the code in the always
block will not be executed.)
In the following code, return
is used to return the result of the function:
define integer function sum (value integer x, value integer y ) as return x+y
You can also use return
by itself to exit from an action function. If you do not exit an action function with return
, it will exit automatically once all the code is executed. A value-returning function, however, must return a value.
Copyright © Stilo International plc, 1988-2008.