(4 > 2) & (a = a) /* true, so result is 1 */
(2 > 4) & (a = a) /* false, so result is 0 */
|
包含 OR
如果至少有一个比较为 true ,那么返回 1 。 例如:
(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 */
&&
互斥 OR
如果仅一个比较 (但不能同时两个比较) 为 true ,那么返回 1 。 例如:
(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
*/
前缀 \ , ¬
逻辑非
求反-返回相反的响应。 例如:
\ 0 /* opposite of 0, so result is 1 */
\ (4 > 2) /* opposite of true, so result is 0 */
IF ((A < B) | (J < D)) & ((M = Q) | (M = D)) THEN ....
以下示例使用逻辑运算符来制定决策。图 1。 使用逻辑表达式的示例
/****************************** 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.'