Jump to content

ANDs and Parenthesis'


Go to solution Solved by Guy Lavoie,

Recommended Posts

Posted (edited)

I have three (3) ANDed conditions that must be met before an action, (THEN), can occur. what is best practice in IOX. 

As I recall from past programming in IOX parenthesis' must be used for  ANDing or ORing at times. XOR and XAND. I always get this stuff mixed up these days!

So, is the following best, (pretty exclusive that the first two conditions must be met), practice...

If
        (
             'Double Garage Door-Sensor' Status is On
         And $Can_Close is 1
        )
    And $s_GarageDoorIsOPEN is 1
 
Then

   .....

or is the code snippet the next best method to ensure that all 3 conditions are in fact met.

If
        (
             'Double Garage Door-Sensor' Status is On
         And $Can_Close is 1
        And $s_GarageDoorIsOPEN is 1
        )
     
Then

....

 

Thanks!!

John

Edited by johnjces
  • Solution
Posted

The second one seems to best reflect what you want to do, visually. Both are actually equivalent. 

Posted
On 7/1/2025 at 6:41 PM, johnjces said:

Thank-you sir!

You don't need parenthesis at all for this.

There is no functional difference between either of the two options you showed as well as no parenthesis at all.

Mostly you would use parenthesis when you have two sets of conditions not connected by the same and/or.

ie.

(1 and 2 and 3) or (4 and 5)

(1 or 2 or 3) and (4 or 5)

 

the following are all  functionally identical

(1 and 2 and 3)

(1 and 2) and 3

1 and (2 and 3)

1 and 2 and 3

(1 and 3) and 2

  • Like 3
Guest
This topic is now closed to further replies.

×
×
  • Create New...