Article ID: 10206
HOWTO: Nested And or Nested OR in IF statement example
HOWTO
Applies To: ITScriptNet V3

What is the syntax for nesting And / Or in an IF statement?

 

DETAILS

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.

 

This article last updated: 5/6/2009 9:25:33 AM
Please help us improve the Knowledge Base by rating this article.
    © 1997-2026 Z-Space Technologies - a BCA Innovations Company - All rights reserved