Language Reference
RETURN Statement
RETURN <(operand)>;
This statement is supported by the IML procedure and the iml action.
The RETURN statement causes a program to return to a previous calling point.
The RETURN statement with an operand is used in function modules that return a value. The operand can be a variable name or an expression. It is evaluated and the value is returned. Parentheses are optional. The RETURN statement without an argument is used to return from a user-defined subroutine.
You can also use the RETURN statement in conjunction with a LINK statement. If a LINK statement has been issued, the RETURN statement returns control to the statement that follows the LINK statement. See the description of the LINK statement. Also, see Chapter 5 for details.
If a RETURN statement is encountered outside a module, execution is stopped as with a STOP statement.
The following examples use the RETURN statement to exit from modules:
start sum1(a, b);
sum = a+b;
return(sum);
finish;
start sum2(s, a, b);
s = a+b;
return;
finish;
x = sum1(2, 3);
run sum2(y, 4, 5);
print x y;
Figure 368: Return from Module Calls
| x | y |
|---|---|
| 5 | 9 |