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
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...