Preventing translation to uppercase
The language processor generally translates alphabetic characters to uppercase before processing them. The alphabetic characters can be within a program , such as words in a REXX instruction, or they can be external to a program and processed as input. You can prevent the translation to uppercase as follows:
Characters within a program
To prevent translation
of alphabetic characters in
a program
to
uppercase, simply enclose the characters in single or double quotation
marks. The language processor does not change numbers and special
characters, regardless of whether they are in quotation marks.
Suppose
you use a SAY instruction with a phrase containing a mixture of
alphabetic
characters, numbers, and special characters; the language processor
changes only the alphabetic characters.
a program
is
processed exactly as typed. This is important in the following situations:
SAY
The bill for lunch comes to £123.51!
results
in:
THE
BILL FOR LUNCH COMES TO £123.51!
(This
example assumes none of the words are the names of variables that
have been assigned other values.)
- For output that must be lowercase or a mixture of uppercase and lowercase.
- To ensure that commands are processed correctly. For example, if a variable name in a program is the same as a command name, the program can end in error when the command is issued. It is a good programming practice to avoid using variable names that are the same as commands and to enclose all commands in quotation marks.
Characters input to a program
When reading input or passing input from another program , the language processor also changes alphabetic characters to uppercase before processing them. To prevent translation to uppercase, use the PARSE instruction.
For example, the following
program
reads
input from the terminal and sends this information to the terminal
output device.
Figure 1. Example of Reading Input and Writing Output
/************************** REXX
***********************************/
/* This REXX
program
gets the name of an animal from the input */
/* stream and sends it to the terminal. */
/*******************************************************************/
PULL animal /* Get the animal name.*/
SAY animal
If the input is
tyrannosaurus
, the language
processor produces the output:
TYRANNOSAURUS
Now
if the input is
TyRannOsauRus
, the output is:
TyRannOsauRus
Exercises: running and modifying the example programs
You can write and run the preceding example. Now change the PULL instruction to a PARSE PULL instruction and note the difference.