Jump to content

Flow-control structures: Difference between revisions

→‎{{header|REXX}}: added FUNCTION INVOCATION section. -- ~~~~
(→‎{{header|REXX}}: changed case of text to match the header case, order sections in alphabetical order. -- ~~~~)
(→‎{{header|REXX}}: added FUNCTION INVOCATION section. -- ~~~~)
Line 1,622:
=={{header|REXX}}==
===call===
The CALL statement immediately transfertransfers control to a named subroutine, and the CALL statement may have any number (or none) parameters.   (However, most REXXes have some practical limit to the number of arguments, usually at least 50).
 
The named subroutine may or may not return a   RESULT   (which is similar to a return code, but REXX allows character strings as well).
 
(Also, see '''function invocation''' below.)
<lang rexx>numeric digits 1000 /*prepare for some gihugeic numbers.*/
...
Line 1,653 ⟶ 1,655:
 
exit expression</lang>
 
===function invocation===
A function invocation (similar to a CALL) immediately transfers control to a named function (subroutine), and the function/subroutine invocation statement may have any number (or none) parameters. &nbsp; (However, most REXXes have some practical limit to the number of arguments, usually at least 50).
 
The named function/subroutine must return a &nbsp; RESULT &nbsp; (which is similar to a return code, but REXX allows character strings as well).
 
If no &nbsp; RESULT &nbsp; is returned, REXX generates a syntax error (which may be trapped).
 
(Also, see '''call''' statement above.)
<lang rexx>numeric digits 1000 /*prepare for some gihugeic numbers.*/
...
n=4
say n'!=' factorial(n)
exit
/*──────────────────────────────────FACTORIAL subroutine────────────────*/
factorial: parse arg x
!=1
do j=2 to x
!=!*j
end /*j*/
return !</lang>
 
===iterate===
Cookies help us deliver our services. By using our services, you agree to our use of cookies.