Flow-control structures: Difference between revisions

Content added Content deleted
(→‎exit: corrected text concerning the EXIT statement, added other verbage. -- ~~~~)
m (→‎return: added text to explain that the program may be a REXX subroutine or function. -- ~~~~)
Line 1,632: Line 1,632:


===return===
===return===
The RETURN statement terminates the running (REXX) program and passes control to the invoking program (it could be the shell/host/supervisor program). If the invoking program isn't a REXX program, the RETURN statement acts like an EXIT.
The RETURN statement terminates the running (REXX) program (which could be a subroutine or function) and passes control to the invoking program (it could be the shell/host/supervisor program).

If the invoking program isn't a REXX program, the RETURN statement acts like an EXIT statement.


If the invoker is a REXX program and the RETURN statement has no EXPRESSION coded, and the invoker expects a RESULT, a SYNTAX condition (error) is raised --- which usually results in an abnormal termination of the invoking REXX program (this condition can be trapped, however).
If the invoker is a REXX program and the RETURN statement has no EXPRESSION coded, and the invoker expects a RESULT, a SYNTAX condition (error) is raised --- which usually results in an abnormal termination of the invoking REXX program (this condition can be trapped, however).
Line 1,638: Line 1,640:


return expression</lang>
return expression</lang>

===signal===
===signal===
The SIGNAL statement can be thought of as a GO TO statement, however, on issuance of a SIGNAL statement, all executing DO loops and SELECTs are terminated. Essentially, that means that there is no real way to re-enter a DO loop once a SIGNAL statement is used.
The SIGNAL statement can be thought of as a GO TO statement, however, on issuance of a SIGNAL statement, all executing DO loops and SELECTs are terminated. Essentially, that means that there is no real way to re-enter a DO loop once a SIGNAL statement is used.