ibm midrange - Boolean order of operation in RPGLE -


why below code result in true if type = 7 , seq = 224?

rpgle free form:

if (type = 6 or                      type = 7 or                      type = 9) ,                    not (seq = 224 or seq=249); 

i had rewrite to:

if (type = 6 or                      type = 7 or                      type = 9) ,                    seq <> 224 ,      seq <> 249; 

but why? guessing has not operator.

well, not has higher precedence and or or rpg iv reference manual operator precedence

  1. ()
  2. built-in functions, user-defined functions
  3. unary +, unary -, not
  4. **
  5. *, /
  6. binary +, binary -
  7. =, <>, >, >=, <, <=
  8. and
  9. or

however, expression show should evaluate false...

**free   dcl-s flag ind;  dcl-s seq int(5) inz(224);  dcl-s type int(5) inz(7);     flag = (type = 6 or            type = 7 or            type = 9) ,             not (seq = 224 or seq=249);     dsply ('flag=' + flag);    *inlr = *on;    return;  

joblog shows:

dsply flag=0


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -