Talk:Flow-control structures: Difference between revisions

→‎REXX Return: an example showing all flavors
(→‎REXX Exit: Should Call On be described?)
(→‎REXX Return: an example showing all flavors)
 
(5 intermediate revisions by 2 users not shown)
Line 33:
 
The text does not consider the Return from a subroutine or function. It should! --[[User:Walterpachl|Walterpachl]] 17:12, 28 January 2013 (UTC)
 
::: The '''RETURN''' text has been updated. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 17:44, 17 December 2013 (UTC)
 
:::: What I see is wrong :-( Please reconsider the Return from a, internal subroutine or function! ..[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 18:39, 17 December 2013 (UTC)
 
::::: The RETURN text mentions "which could be a subroutine or function)" ... and passed control to the invoking program (the program that called or invoked the subroutine/function).   If you think the phrase could use clarification, then feel free to add more verbage.   It's sometimes not clear to readers what is being referred to which REXX code is being executed (or being called/invoked) when the REXX code calls/invokes an internal REXX program versus an external REXX program.   This can be an area of misunderstanding, and certainly, an area of confusion.   I'm not sure how to succinctly put that into words that is concise and easy to understand without getting to wording that is too obtuse.   I don't want to re-write a REXX tutorial on the RETURN statement. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 19:07, 17 December 2013 (UTC)
--------------------------
How about this:
<pre>RETURN returns control, and possibly a result, from a Rexx program or routine to the point of
its invocation.
If no internal routine (subroutine or function) is active,
RETURN and EXIT are identical in their effect on the program that is run. (See EXIT.)
If called as a function, an expression must be present, its value is returned to the point of
invocation.
If called as a routine, control is passed back to the caller.
If an expression is present, it is evaluated and the Rexx special variable RESULT is set
to the value of expression. Otherwise the special variable RESULT is dropped.</pre>
--[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 21:01, 17 December 2013 (UTC)
:::::: The following example shows all the flavors (and a surprise when I invoke the program as rexx ret 1 (on Windows using ooRexx)! The control structure seems to get broken)
<lang rexx>Call sub 1
s=sub(2)
Say 's='s
sub: parse Arg a
Select
When a=1 Then Say 'we''ll return to line 2'
When a=2 Then Say 'we''ll return to the expression in line 2'
Otherwise Say 'we''ll exit the program'
End
Return a</lang>
Output:
<pre>we'll return to line 2
we'll return to the expression in line 2
s=2
we'll exit the program</pre>
 
== REXX Exit ==
Line 53 ⟶ 87:
and back in Caller. Got 4711 from Called</pre>
--[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 09:24, 17 December 2013 (UTC)
 
::: The '''EXIT''' text has been updated. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 17:39, 17 December 2013 (UTC)
 
-----
 
: And an additional idea/question: ooRexx has Call on exception handling (similar to Signal On). Do other Rexxes have that too?? --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 09:28, 17 December 2013 (UTC)
2,295

edits