如果type = 7和seq = 224,为什么下面的代码会生成true?
RPGLE自由形式:
if (type = 6 or
type = 7 or
type = 9) and
not (seq = 224 or seq=249);
我不得不把它重写为:
if (type = 6 or
type = 7 or
type = 9) and
seq <> 224 and
seq <> 249;
但为什么呢?我猜它与NOT运算符有关。
答案 0 :(得分:3)
好吧,NOT
的优先级高于AND
或OR
RPG IV Reference manual operator precedence
但是,您显示的表达式应该评估为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显示:
DSPLY标志= 0