Reputation: 473
Why does the below code result in true if type = 7 and seq = 224?
RPGLE free form:
if (type = 6 or
type = 7 or
type = 9) and
not (seq = 224 or seq=249);
I had to rewrite it to:
if (type = 6 or
type = 7 or
type = 9) and
seq <> 224 and
seq <> 249;
but why? I am guessing it has something to do with the NOT operator.
Upvotes: 0
Views: 2321
Reputation: 23783
Well, NOT
has a higher precedence than AND
or OR
RPG IV Reference manual operator precedence
However, the expression you show should evaluate to 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) and
not (seq = 224 or seq=249);
dsply ('Flag=' + flag);
*INLR = *ON;
return;
Joblog shows:
DSPLY Flag=0
Upvotes: 3