Chapter 3. Using Variables And Expressions; Using Variables - IBM TSO/E REXX User Manual

Table of Contents

Advertisement

Chapter 3. Using Variables and Expressions

Using Variables. . . . . . . . . . . . . . . . . . . . . . . . . 25
This chapter describes variables, expressions, and operators, and explains how to
use them in REXX execs.
One of the most powerful aspects of computer programming is the ability to process
variable data to achieve a result. The variable data could be as simple as two
numbers, the process could be subtraction, and the result could be the answer.
answer = number1 - number2
Or the variable data could be input to a series of complex mathematical
computations that result in a 3-dimensional animated figure.
Regardless of the complexity of a process, the premise is the same. When data is
unknown or if it varies, you substitute a symbol for the data, much like the "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 that represents a value. A variable
can contain either single- or double-byte characters, or a combination of single- and
double-byte characters. (Double-byte characters are valid only if you include
OPTIONS ETMODE as the first instruction of your exec.) The following variable big
represents the value one million or 1,000,000.
© Copyright IBM Corp. 1988, 2001
. . . . . . . . . . . . . . . . . . . . . . . 26
Variable Values . . . . . . . . . . . . . . . . . . . . . . . . 27
. . . . . . . . . . . . . . . . . . . . . . . 28
Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . 28
. . . . . . . . . . . . . . . . . . . . . . . . . 29
Order of Evaluation . . . . . . . . . . . . . . . . . . . . . 29
Using Arithmetic Expressions. . . . . . . . . . . . . . . . . . 30
Comparison Operators . . . . . . . . . . . . . . . . . . . . . 30
The Strictly Equal and Equal Operators . . . . . . . . . . . . . . 31
Using Comparison Expressions . . . . . . . . . . . . . . . . . 31
Exercises - Using Comparison Expressions . . . . . . . . . . . . 32
Logical (Boolean) Operators . . . . . . . . . . . . . . . . . . . 32
Using Logical Expressions. . . . . . . . . . . . . . . . . . . 33
Exercises - Using Logical Expressions . . . . . . . . . . . . . . 34
Concatenation Operators . . . . . . . . . . . . . . . . . . . . 34
Using Concatenation Operators . . . . . . . . . . . . . . . . . 34
Priority of Operators . . . . . . . . . . . . . . . . . . . . . . 35
Tracing Operations . . . . . . . . . . . . . . . . . . . . . . 37
Tracing Results. . . . . . . . . . . . . . . . . . . . . . . . 38
Exercises - Using the TRACE Instruction . . . . . . . . . . . . . 38
. . . . . . . . . . . . . . . . 36
. . . . . . . . . . . . 37
25

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents