PxPlus User Forum

Twitter Twitter Twitter

Author Topic: incorrect evaluation  (Read 1138 times)

Thomas Bock

  • Diamond Member
  • *****
  • Posts: 177
    • View Profile
incorrect evaluation
« on: October 16, 2019, 09:45:34 AM »
In my opinion the following condition should print a star
Code: [Select]
if 1 or 0 and 0 then print "*"It is the same as
Code: [Select]
if 1 or (0 and 0) then print "*"or
Code: [Select]
1+0*0For better understanding we will add the brackets.
PxPlus doesn't print a star. I'm curious, what am I missing?

James Zukowski

  • Diamond Member
  • *****
  • Posts: 297
    • View Profile
Re: incorrect evaluation
« Reply #1 on: October 16, 2019, 10:06:11 AM »
The 'AND' and 'OR' operators have the same precedence level, so they are evaluated left-to-right. In this case, it essentially works out to be:
Code: [Select]
if (1 or 0) and 0 then print "*"
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services