IBM SC34-5764-01 Server User Manual


 
Chapter 3. Using Variables and Expressions
This chapter describes variables, expressions, and operators, and explains how to use them in REXX
programs.
Program Variables
One of the most powerful aspects of computer programming is the ability to process variable data to
achieve a result. Regardless of the complexity of a process, when data is unknown or varies, you
substitute a symbol for the data. This is much like substituting x and y in an algebraic equation.
x=y+29
The symbol, when its value can vary, is called a variable. A group of symbols or numbers that must be
calculated to be resolved is called an expression.
Using Variables
A variable is a character or group of characters representing a value. A variable can contain either single-
or double-byte characters or both. (Double-byte characters are valid only if OPTIONS ETMODE is the first
instruction of your program.) The following variable big represents the value one million or 1,000,000.
big = 1000000
Variables can refer to different values at different times. If you assign a different value to big, it gets the
value of the new assignment, until it is changed again.
big = 999999999
Variables can also represent a value that is unknown when the program is written. In the following
example, the user's name is unknown, so it is represented by the variable who.
/* Gets name from current input stream */
PARSE PULL who /* and puts it in variable "who" */
Variable Names
A variable name, the part that represents the value, is always on the left of the assignment statement and
the value itself is on the right. In the following example, the variable name is variable1.
variable1 = 5
SAY variable1
As a result of the preceding assignment statement, the language processor assigns variable1 the value 5,
and the SAY produces:
5
Variable names can consist of:
A–Z uppercase alphabetic
a–z lowercase alphabetic
0–9 numbers
?!._ special characters
X'41'–X'FE'
double-byte character set (DBCS) characters. (OPTIONS ETMODE must be the first instruction in
your program for these characters to be valid in a variable name.)
Restrictions on the variable name are:
© Copyright IBM Corp. 1992, 2009 19