Using Logical Expressions

You can use logical expressions in complex conditional instructions and 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.
Figure 1. Example Using Logical Expressions
/****************************** REXX ********************************/
/* This program 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:
IF ((season = 'WINTER') | (snowing ='YES')) & (broken_leg ='NO') THEN
     \______________/      \____________/       \_____________/
          false                 true                 true
             \___________________/                    /
                    true                             /
                      \_____________________________/
                                    true
As a result, when you run the program, it produces the result:
Go skiing.

Reference Reference

Feedback


Timestamp icon Last updated: Tuesday, 7 January 2014


http://pic.dhe.ibm.com/infocenter/cicsts/v5r1/topic/com.ibm.cics.rexx.doc//dfhrx/dfhrx00035.html