|
|
|
|
|
- Overview
- Details
- Loose equality and very loose equality
- Equality and comparison: Real containing more than 6 different decimal places
- Comparison intervals
- Comparison operators and UNICODE
- Comparing instances of structures and instances of classes
- IN operator
The comparison operators can be divided into several categories: | | Equality | - Strict equality: =
- Flexible equality: ~=
- Very loose equality: ~~
- Starts with: [=
| Comparison | - Different: <>
- Less than or equal to: <=
- Greater than or equal to: >=
- Strictly less than: <
- Strictly greater than: >
- Starts with: [=
- Starts with: [~ (ignores leading spaces and case).
- Starts with: [~~ (ignores all spaces, punctuation and case).
- Comparison with a list of values: IN
- Contains: [=]
- Contains: [~] (ignores case and leading and trailing spaces).
- Contains: [~~] (ignores all spaces, punctuation and case)
- Ends with: =]
- End with: ~] (ignores trailing spaces and case)
- End with: ~~] (ignores spaces, punctuation and case)
| Comparison interval | - Strictly between: < .. < (and the opposite)
Value1 < x < Value2 - Between: < .. <= AND < .. = < (and vice versa)
Value1 <= x AND x <= Value2 - Between (inclusive boundaries): <= <= (and vice versa)
Value1 <= x <= Value2 - Between (including bounds): x A y
|
The comparison operators can be used with all the types of operands. The result of a comparison expression is a boolean. Loose equality and very loose equality The loose equality (~=) only applies to the character strings (except the fixed strings). This operator allows you to: - make no difference between the uppercase characters and the lowercase characters,
- ignore the space characters found before and after the string whose test must be run,
- ignore the lowercase accented characters.
To ignore the space characters, the punctuation characters and the CR characters inside the strings, use the very loose equality (~~). HFSQL Equivalence: To find the very flexible equality equivalence when searching on a Text key in an HFSQL data file, it is necessary to configure the following options when describing the field in the analysis:
"Smith" = "SMITH" // Returns False "Smith" ~= "SMITH" // Returns True " Smith" ~= "SMITH" // Returns True " Smith" ~= "Smith" // Returns True "C'est l'été" ~= "C'est l'ete" // Returns True "I.R.S." ~~ "IRS" // Returns True Equality and comparison: Real containing more than 6 different decimal places The test of equality between two real numbers is performed according to the first 6 decimal places. Indeed, the rounding errors caused by the internal coding of the reals require a specific test. This test must be run by comparing the difference between the two values to test and a reference value. Depending on the type of your application, this value can be equal to 0.00001 or even less. This rounding management is not specific to WINDEV, WEBDEV and WINDEV Mobile. It is common to all the programming languages that handle the reals in binary format. Diff, R1, R2 are real Diff = 0.00001 IF Abs(1-(R1/R2)) < Diff THEN // R1 and R2 are equal ELSE // R1 and R2 are different END Comparison intervals The comparison intervals are used to simplify the syntax of complex comparisons. Some examples of identical comparisons: - Example 1:
- IF x>5 AND x<10 THEN...
- IF 5<x<10 THEN...
- Example 2:
- IF x>=5 AND x<=10 THEN...
- IF x=5 TO 10 THEN ...
 Not supported.
MyArray is array of 5 strings I is int MyArray[1] = "Smith" MyArray[2] = "Aida" MyArray[3] = "Parapoline" MyArray[4] = "Moulin" MyArray[5] = "Clark" FOR I = 1 TO 5 IF "B" < MyArray[I] <= "M" THEN Trace(MyArray[I]) // Displays Smith and Clark END Comparison operators and UNICODE The available operators are as follows: - "=": Strict equality
- "<>": Difference
- "[=": Starts with
- "[~": Starts with, ignoring spaces at the beginning of the string and ignoring case.
- "[~~": Starts with ignoring all spaces, punctuation characters and case..
- Contains: [=]
- Contains: [~]: Contains in case-insensitive mode.
- Contains: [~~]: Contains ignoring all spaces, punctuation characters and case..
- Ends with: =]
- Ends with: ~]: End with ignoring trailing spaces and ignoring case..
- End with: ~~]: End with ignoring spaces, punctuation and case..
- "<", "<=", ">=", ">": Strictly less than, less than or equal to, greater than or equal to, strictly greater than
You have the ability to use ANSI strings, Unicode strings and buffers in the different parameters of the comparison. The following conversion rule is used for the Ansi systems (Windows or Linux): - If at least one of the strings is a buffer, all the strings are converted to buffers and the operation is performed with buffers,
- If the first condition is not met and there is at least one Unicode string, all the strings are converted to Unicode and the operation is performed in Unicode (the conversion is performed with the current character set, if necessary),
- Otherwise, the operation is performed in Ansi.
The conversion rule used is as follows for Unicode systems (Windows CE): - If at least one of the strings is a buffer, all the strings are converted to buffers and the operation is performed with buffers,
- Otherwise, the operation is performed in Unicode.
IN operator The IN operator is used to compare a value to a list of values. Its evaluation returns a boolean. Example: MyValue is int MyResult is boolean MyValue = 10 MyResult = (MyValue IN(1,4,6,10)) The list of values can contain literal values or variables whose value will be evaluated before the comparison is performed. Example: MyValue is int MyOtherValue is int MyResult is boolean MyValue = 10 MyOtherValue = 15 MyResult = (MyValue IN(1,4,6,10,MyOtherValue))
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|