Using parentheses in your formulas

Home Forum Formula and Condition Editor Using parentheses in your formulas

This topic contains 0 replies, has 1 voice, and was last updated by  Dennis @ PerfectForms 4 years, 4 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #7168

    When stringing together more than one set of conditions in a formula parentheses are required in the logic.  Good form builders strive to create logical conditions that are clear and correct. Parentheses in conditionals help with both. These cues are necessary because:

     ·       In PerfectForms they are required for Boolean linked conditions in formulas. Any formula conditions linked with the operators logical AND, and logical OR must be contained inside parentheses.

    They reduce the work required to understand the code.

    ¬∑¬†¬†¬†¬†¬†¬†¬†¬†¬ They provide confirmation of the developer’s intent.

    ·         Extra parentheses, just like indentations, whitespace, and other style standards, help visually organize the formula in a logical way.

    ·         It helps the next person to work on your code understand your logic and thus eliminates errors.

    ¬

    Formulas in conditions without parentheses are a recipe for mistakes. They can be bugs that are hard to find–because often an incorrect condition will behave correctly most of the time, and only occasionally fail.

    ¬

    Here is an example of how I construct my Boolean conditions:

    ¬

    (Field A

    ¬

    =

    ¬

    Print)

    ¬

    AND

    ¬

    (Radio Button Group 5 Value

    ¬

    =

    ¬

    3)

    ¬

    AND

    ¬

    (Checkbox 2

    ¬

    <>¬

    ¬

    Checked (yes))

    ¬

    AND

    ¬

    (Field G

    ¬

    <>¬

    ¬

    save)

     

    ¬

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.