What is the syntax for nesting And / Or in an IF statement?
Below is an example of a nested “and”. There should be no limit to the number of nested And/Or; only to the length of the line.
IF(AND (@W@ = "W", AND(@X@ = "X", AND (@Y@ = "Y", @Z@ = "Z"))))
The element values can also be used instead of the variable values, as shown in this example:
IF(AND ($Pr1.El1$ = "W", AND($Pr1.El2$ = "X", AND (@Y@ = "Y", @Z@ = "Z"))))
In ITScriptNet 3.0 and higher, yuo may also use the new && operator instead of nesting the AND function. Here is an example of using the && operator.
IF(($Pr1.El1$ = "W") && ($Pr1.El2$ = "X") && (@Y@ = "Y") && (@Z@ = "Z"))
The parenthesis are around each test are recommended to ensure that the statement is not ambiguous.