4D v14.3Comparison Operators |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14.3
Comparison Operators
|
Operation | Syntax | Returns | Expression | Value |
Equality | String = String | Boolean | "abc" = "abc" | True |
"abc" = "abd" | False | |||
Inequality | String # String | Boolean | "abc" # "abd" | True |
"abc" # "abc" | False | |||
Greater than | String > String | Boolean | "abd" > "abc" | True |
"abc" > "abc" | False | |||
Less than | String < String | Boolean | "abc" < "abd" | True |
"abc" < "abc" | False | |||
Greater than or equal to | String >= String | Boolean | "abd" >= "abc" | True |
"abc" >= "abd" | False | |||
Less than or equal to | String <= String | Boolean | "abc" <= "abd" | True |
"abd" <= "abc" | False | |||
Contains keyword | String % String | Boolean | "Alpha Bravo" % "Bravo" | True |
"Alpha Bravo" % "ravo" | False | |||
Picture % String | Boolean | Picture_expr % "Mer" | True (*) |
(*) If the keyword "Mer" is associated with the picture stored in the picture expression (field or variable).
Important: Additional information about string comparisons are provided at the end of this section.
Operation | Syntax | Returns | Expression | Value |
Equality | Number = Number | Boolean | 10 = 10 | True |
10 = 11 | False | |||
Inequality | Number # Number | Boolean | 10 #11 | True |
10 # 10 | False | |||
Greater than | Number > Number | Boolean | 11 > 10 | True |
10 > 11 | False | |||
Less than | Number < Number | Boolean | 10 < 11 | True |
11 < 10 | False | |||
Greater than or equal to | Number >= Number | Boolean | 11 >= 10 | True |
10 >= 11 | False | |||
Less than or equal to | Number <= Number | Boolean | 10 <= 11 | True |
11 <= 10 | False |
Operation | Syntax | Returns | Expression | Value |
Equality | Date = Date | Boolean | !1/1/97! =!1/1/97! | True |
!1/20/97! =!1/1/97! | False | |||
Inequality | Date # Date | Boolean | !1/20/97! # !1/1/97! | True |
!1/1/97! # !1/1/97! | False | |||
Greater than | Date > Date | Boolean | !1/20/97! > !1/1/97! | True |
!1/1/97! > !1/1/97! | False | |||
Less than | Date < Date | Boolean | !1/1/97! < !1/20/97! | True |
!1/1/97! < !1/1/97! | False | |||
Greater than or equal to | Date >= Date | Boolean | !1/20/97! >=!1/1/97! | True |
!1/1/97!>=!1/20/97! | False | |||
Less than or equal to | Date <= Date | Boolean | !1/1/97!<=!1/20/97! | True |
!1/20/97!<=!1/1/97! | False |
Operation | Syntax | Returns | Expression | Value |
Equality | Time = Time | Boolean | ?01:02:03? = ?01:02:03? | True |
?01:02:03? = ?01:02:04? | False | |||
Inequality | Time # Time | Boolean | ?01:02:03? # ?01:02:04? | True |
?01:02:03? # ?01:02:03? | False | |||
Greater than | Time > Time | Boolean | ?01:02:04? > ?01:02:03? | True |
?01:02:03? > ?01:02:03? | False | |||
Less than | Time < Time | Boolean | ?01:02:03? < ?01:02:04? | True |
?01:02:03? < ?01:02:03? | False | |||
Greater than or equal to | Time >= Time | Boolean | ?01:02:03? >=?01:02:03? | True |
?01:02:03? >=?01:02:04? | False | |||
Less than or equal to | Time <= Time | Boolean | ?01:02:03? <=?01:02:03? | True |
?01:02:04? <=?01:02:03? | False |
With:
` vPtrA and vPtrB point to the same object
vPtrA:=->anObject
vPtrB:=->anObject
` vPtrC points to another object
vPtrC:=->anotherObject
Operation | Syntax | Returns | Expression | Value |
Equality | Pointer = Pointer | Boolean | vPtrA = vPtrB | True |
vPtrA = vPtrC | False | |||
Inequality | Pointer # Pointer | Boolean | vPtrA # vPtrC | True |
vPtrA # vPtrB | False |
Character code("A")=Character code("a") // because 65 is not equal to 97
"n"="ñ"
"n"="Ñ"
"A"="å"
// and so on
"Alpha Bravo Charlie"%"Bravo" // Returns True
"Alpha Bravo Charlie"%"vo" ` Returns False
"Alpha Bravo Charlie"%"Alpha Bravo" // Returns False
"Alpha,Bravo,Charlie"%"Alpha" // Returns True
"Software and Computers"%"comput@" // Returns True
Notes:
- 4D uses the ICU library for detecting keywords. For more information about the rules implemented, please refer to the following address:http://www.unicode.org/unicode/reports/tr29/#Word_Boundaries.
- In the Japanese version, instead of ICU, 4D uses Mecab by default for detecting keywords. For more information, please refer to Support of Mecab (Japanese version).
"abcdefghij"="abc@"
The wildcard character must be used within the second operand (the string on the right side) in order to match any number of characters. The following expression is FALSE, because the @ is considered only as a one character in the first operand:
"abc@"="abcdefghij"
The wildcard means “one or more characters or nothing”. The following expressions are TRUE:
"abcdefghij"="abcdefghij@"
"abcdefghij"="@abcdefghij"
"abcdefghij"="abcd@efghij"
"abcdefghij"="@abcdefghij@"
"abcdefghij"="@abcde@fghij@"
On the other hand, whatever the case, a string comparison with two consecutive wildcards will always return FALSE. The following expression is FALSE:
"abcdefghij"="abc@@fg"
When the comparison operator is or contains a < or > symbol, only comparison with a single wildcard located at the end of the operand is supported:
"abcd"<="abc@" // Valid comparison
"abcd"<="abc@ef"/Not a valid comparison/
Tip:If you want to execute comparisons or queries using @ as a character (and not as a wildcard), you have two options:
($vsValue≤Length($vsValue)≥="@")
- the following expression will be evaluated correctly:
(Character code($vsValue≤Length($vsValue)≥)#64)
Product: 4D
Theme: Operators
Bitwise Operators
Date Operators
Logical Operators
Numeric Operators
Operators
Picture Operators
Time Operators
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)
Inherited from :
Comparison Operators ( 4D v12.4)
Parent of :
Comparison Operators ( 4D v13.5)