Compare
- Last UpdatedJan 11, 2023
- 1 minute read
- PI System
- PI Server 2024 R2
- PI Server
Compare two strings using wildcard characters ("*" and "?") or compare two operands using logical operators and deadband value.
Syntax
Compare {[(s1, s2 [, caseSensitive])]|[x1, x2, op, deadband]}
Arguments
-
s1, s2
string (s2 can contain wildcard characters)
-
caseSensitive
Optional flag indicating if the comparison is case sensitive. If False (the default), the comparison is not case-sensitive. If True, the comparison is case-sensitive
-
x1, x2
Numeric value (integer or real number) or time expression
-
op
An operator used for comparison. Must be one of the following operators, or a variable defined as one of these: <, >, <=, >=
-
deadband
Numeric value (integer or real number) or timespan. Deadband specifies a buffer (tolerance) around x2 and prevents repeated alerts when the value fluctuates within the deadband range
Returns
-
True if s1 = s2
-
True if x1 <op> x2 is true, and uses deadband value for subsequent evaluations
False otherwise
Exceptions
Wildcard characters in s1 are treated literally and not as wildcards
The deadband value is applied to x2, not x1
Example
-
Compare('att1', 100, "<=", 5)
[Returns True if 'att1' is less than or equal to 100, and uses the deadband value of 5 for subsequent evaluations]
-
Compare("What", "what", True)
[Returns False]
-
Compare("b", "a")
[Returns False]
-
Compare("What", "wha?")
[Returns True]
-
Compare("What", "wh")
[Returns False]