Optional parameters: Difference between revisions

m
→‎{{header|REXX}}: changed a comment to a boxed comment, changed some comments.
m (→‎{{header|REXX}}: changed a comment to a boxed comment, changed some comments.)
Line 1,673:
<br><br>The REXX language doesn't have any native sorting functions, so you have to write your own sorting subroutine.
<lang rexx>sortStrings: procedure expose @. /*stemmed array is named: @. */
col=1; reverse='NO'; order='LEXICOGRAPHIC' /*set thesome defaults.*/
arg options
do j=1 for words(options); x=word(options,j)
 
select
when datatype(x, 'W') then col=x/1
when pos('=', x)==0 then order=x
otherwise parse var x nam '=' value
end /*select*/
end /*j*/
/*╔═══════════════════════════════════════════════════════════╗
 
/*check for errors here: COL isn't a positive, integer ···, */
/* REVERSE value isn't NO or YES, */
/* ORDER value is recognized ...··· */
╚═══════════════════════════════════════════════════════════╝*/
 
... main body of string sort here ...
return /*stick a fork in it, we're done.*/</lang>
 
return</lang>
An example use is:
<lang rexx>/*REXX example to useuses the SortStrings subroutine with optional args. */
/*...···define array (@.nnn) of strings here...···*/
call sortStrings 'Reverse=no' 3
/*stick a fork in it, we're done.*/</lang>
return</lang>
 
=={{header|Ruby}}==