String case: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) m Move Peloton example to correct position |
m →{{header|REXX}}: changed/added comments and whitespace, changes some version names, changed indentations. |
||
Line 1,679:
=={{header|REXX}}==
===
The following code will execute correctly in '''ASCII''' and '''EBCDIC.
<lang rexx>abc = "abcdefghijklmnopqrstuvwxyz" /*define all
abcU = translate(abc) /* " " uppercase "
x = 'alphaBETA' /*define a string to a REXX variable. */
y = translate(x) /*uppercase X and store
z = translate(x, abc, abcU) /*
===
The following code will execute correctly in '''ASCII''' and '''EBCDIC.
<lang rexx>x = "alphaBETA" /*define a string to a REXX variable. */
parse upper var x y /*uppercase X and store
parse lower var x z /*lowercase X " " " ───► Z */
===
The following code will execute correctly in '''ASCII''' and '''EBCDIC.
<lang rexx>x = 'alphaBETA' /*define a string to a REXX variable. */
y = upper(x) /*uppercase X and store
z = lower(x) /*lowercase X " " " ───► Z */
===
The following code will execute correctly in '''ASCII''' and '''EBCDIC.
<lang rexx>x = "alphaBETA" /*define a string to a REXX variable. */
y=x; upper y /*uppercase X and store
parse lower var x z /*lowercase Y " " " ───► Z */
===
The following code will execute correctly in '''ASCII''' and '''EBCDIC.
<lang rexx>/*REXX
x= "alef bet gimel dalet he vav zayin het tet yod kaf lamed mem nun samekh",
"ayin pe tzadi qof resh shin tav." /*the "old" spelling of Hebrew letters.
y= capitalize(x) /*capitalize each word in the string. */
say x /*
say y /*
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
capitalize: procedure; parse arg z; $=' 'z
abc = "abcdefghijklmnopqrstuvwxyz"
_=' 'substr(abc,j,1); _U=_
$=changestr(_, $, _U) /*maybe capitalize some word(s). */
end /*j*/
return substr($, 2)
Some older REXXes don't have a '''changestr''' BIF, so one is included here ──► [[CHANGESTR.REX]]. <br>
<br>
Line 1,742:
<br><br>
===
The following code will execute correctly in '''ASCII''' and '''EBCDIC.
<lang rexx>/*REXX
abc = "abcdefghijklmnopqrstuvwxyz" /*define all the lowercase letters. */
abcU = translate(abc) /* " " " uppercase " */
x = 'alphaBETA' /*define a string to a REXX variable. */
y = translate(x, abc || abcU, abcU || abc) /*swap case of X and store it ───► Y */
say x
say y
/*stick a fork in it, we're all done. */</lang>
'''output'''
<pre>
|