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
- ()
- built-in functions, user-defined functions
- unary +, unary -, not
- **
- *, /
- binary +, binary -
- =, <>, >, >=, <, <=
- and
- 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
Post a Comment