RETURN
Returns to the procedure that called the current procedure. (The return
is to the statement following the one that called the current procedure.)
RETURN is can be used in the ON_ERROR section of a procedure or to return
a value or status in a procedure.
Syntax:
RETURN [value]
Parameters
value Optionally, a value to be returned to the calling procedure,
such as a variable or a status value (1 for true; 0 for
false).
Examples
1. In the following procedure, RETURN is used in the ON_ERROR section of
a procedure (in this case, to attach to the parent process):
PROCEDURE user_attach_to_parent
ON_ERROR
IF ERROR = TPU$_NOPARENT
THEN
MESSAGE ("Not running TPU in a subprocess.");
RETURN;
ENDIF;
ENDON_ERROR;
ATTACH;
ENDPROCEDURE;
2. In the following procedure, RETURN passes a value to the calling
procedure (in this case, a keyword for a key pressed after the shift
or GOLD key):
PROCEDURE user_get_gold_key
LOCAL gold_key; ! keyword for key pressed after GOLD
SET (SHIFT_KEY, LAST_KEY);
gold_key := KEY_NAME (READ_KEY, SHIFT_KEY);
RETURN (key_to_shift);
ENDPROCEDURE;
3. In the following procedure, RETURN passes a value (true or false) for
the status of a procedure (in this case, whether the user is at the
end of a line):
PROCEDURE user_at_eol
ON_ERROR
RETURN (1); ! Suppress warning message
ENDON_ERROR;
IF CURRENT_OFFSET = LENGTH (CURRENT_LINE)
THEN
RETURN (1); ! True -- at end of line
ELSE
RETURN (0); ! False -- not at end of line
ENDIF;
ENDPROCEDURE;