Preventing translation to uppercase

The language processor generally translates alphabetic characters to uppercase before processing them. You can prevent the translation to uppercase.

Characters in 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. If 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.

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.

Quotation marks ensure that information in a program is processed exactly as typed. This is important in the following situations:
  • 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.

/************************** 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

To cause the language processor to read input exactly as it is presented, use the PARSE PULL instruction instead of the PULL instruction.

PARSE PULL animal
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.

Note: Start of changeThe following characters might display differently in the REXX online help depending on the code page used in your emulator configuration: @ # $ ¢. See also Syntax notation.End of change