EasyManua.ls Logo

IBM TSO/E REXX

IBM TSO/E REXX
242 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
The logical operators are:
Operator Meaning
& AND
Returns 1 if both comparisons are true. For example:
(4 > 2) & (a = a) /* true, so result is 1 */
(2 > 4) & (a = a) /* false, so result is 0 */
| Inclusive OR
Returns 1 if at least one comparison is true. For example:
(4 > 2) | (5 = 3) /* at least one is true, so result is 1 */
(2 > 4) | (5 = 3) /* neither one is true, so result is 0 */
&& Exclusive OR
Returns 1 if only one comparison (but not both) is true. For
example:
(4 > 2) && (5 = 3) /* only one is true, so result is 1 */
(4 > 2) && (5 = 5) /* both are true, so result is 0 */
(2 > 4) && (5 = 3) /* neither one is true, so result is 0 */
Prefix \ Logical NOT
Returns the opposite response. For example:
\ 0 /* opposite of 0, so result is 1 */
\ (4 > 2) /* opposite of true, so result is 0 */
Using Logical Expressions
Logical expressions are used in complex conditional instructions and can act as
checkpoints to screen unwanted conditions. When you have a series of logical
expressions, for clarification, use one or more sets of parentheses to enclose each
expression.
IF ((A < B) | (J < D)) & ((M = Q) | (M = D)) THEN ...
The following example uses logical operators to make a decision.
Example Using Logical Expressions
/***************************** REXX ********************************/
/* This exec receives arguments for a complex logical expression */
/* that determines whether a person should go skiing. The first */
/* argument is a season and the other two can be 'yes' or 'no'. */
/*******************************************************************/
PARSE ARG season snowing broken_leg
IF ((season = 'winter') | (snowing ='yes')) & (broken_leg ='no')
THEN SAY 'Go skiing.'
ELSE
SAY 'Stay home.'
When arguments passed to this example are "spring yes no", the IF clause
translates as follows:
Using Expressions
Chapter 3. Using Variables and Expressions 33

Table of Contents

Related product manuals