PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Overview
  • Details
  • Flexible equality and very flexible 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
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
The comparison operators can be divided into several categories:
Equality
  • Strict equality: =
  • Flexible equality: ~=
  • Very flexible equality: ~~
  • Starts with: [=
Comparison
  • Different: <>
  • Less than or equal to: <=
  • Greater than or equal to: >=
  • Strictly less than: <
  • Strictly greater than: >
  • Starts with: [=
  • Versions 16 and later
    Starts with: [~ (ignores the space characters found at the beginning of string and the case).
    New in version 16
    Starts with: [~ (ignores the space characters found at the beginning of string and the case).
    Starts with: [~ (ignores the space characters found at the beginning of string and the case).
  • Versions 16 and later
    Starts with: [~~ (ignores all the space characters, the punctuation and the case).
    New in version 16
    Starts with: [~~ (ignores all the space characters, the punctuation and the case).
    Starts with: [~~ (ignores all the space characters, the punctuation and the case).
  • Comparison to a list of values: IN
  • Versions 19 and later
    Contains: [=]
    New in version 19
    Contains: [=]
    Contains: [=]
  • Versions 19 and later
    Contains: [~] (ignores the case and the space characters found at the beginning and end of string).
    New in version 19
    Contains: [~] (ignores the case and the space characters found at the beginning and end of string).
    Contains: [~] (ignores the case and the space characters found at the beginning and end of string).
  • Versions 19 and later
    Contains: [~~] (ignores all the space characters, the punctuation and the case)
    New in version 19
    Contains: [~~] (ignores all the space characters, the punctuation and the case)
    Contains: [~~] (ignores all the space characters, the punctuation and the case)
  • Versions 19 and later
    Ends with: =]
    New in version 19
    Ends with: =]
    Ends with: =]
  • Versions 19 and later
    Ends with: ~] (ignore the space characters at the end of string and the case)
    New in version 19
    Ends with: ~] (ignore the space characters at the end of string and the case)
    Ends with: ~] (ignore the space characters at the end of string and the case)
  • Versions 19 and later
    Ends with: ~~] (ignore the space characters, the punctuation and the case)
    New in version 19
    Ends with: ~~] (ignore the space characters, the punctuation and the case)
    Ends with: ~~] (ignore the space characters, the punctuation and the case)
Comparison interval
  • Strictly included between: < < (and conversely)
  • Included between: < <= and <= < (and conversely)
  • Included between (including bounds): <= <= (and conversely)
  • Included between (including bounds): x TO y
The comparison operators can be used with all the types of operands.
The result of a comparison expression is a boolean.
Details

Flexible equality and very flexible equality

The flexible 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 flexible equality (~~).
HFSQL equivalence: To retrieve the equivalence to the very flexible equality when performing a search on a text key in a HFSQL data file, the following options must be configured when the item is described 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. Therefore, the line:
IF x>5 AND x<10 THEN ...
can be replaced by:
IF 5<x<10 THEN ...
The line:
IF x>=5 AND x<=10 THEN ...
can be replaced by:
IF x=5 TO 10 THEN ...
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
  • Versions 16 and later
    "[~": Starts with while ignoring the space characters found at the beginning of the string and while ignoring the case.
    New in version 16
    "[~": Starts with while ignoring the space characters found at the beginning of the string and while ignoring the case.
    "[~": Starts with while ignoring the space characters found at the beginning of the string and while ignoring the case.
  • Versions 16 and later
    "[~~": Starts with while ignoring the space characters, the punctuation characters and the case.
    New in version 16
    "[~~": Starts with while ignoring the space characters, the punctuation characters and the case.
    "[~~": Starts with while ignoring the space characters, the punctuation characters and the case.
  • Versions 19 and later
    Contains: [=]
    New in version 19
    Contains: [=]
    Contains: [=]
  • Versions 19 and later
    Contains: [~]: Contains while ignoring the case.
    New in version 19
    Contains: [~]: Contains while ignoring the case.
    Contains: [~]: Contains while ignoring the case.
  • Versions 19 and later
    Contains: [~~]: Contains while ignoring all the space characters, the punctuation characters and the case.
    New in version 19
    Contains: [~~]: Contains while ignoring all the space characters, the punctuation characters and the case.
    Contains: [~~]: Contains while ignoring all the space characters, the punctuation characters and the case.
  • Versions 19 and later
    Ends with: =]
    New in version 19
    Ends with: =]
    Ends with: =]
  • Versions 19 and later
    Ends with: ~]: Ends with while ignoring the space characters found at the end of the string and while ignoring the case.
    New in version 19
    Ends with: ~]: Ends with while ignoring the space characters found at the end of the string and while ignoring the case.
    Ends with: ~]: Ends with while ignoring the space characters found at the end of the string and while ignoring the case.
  • Versions 19 and later
    Ends with: ~~]: Ends with while ignoring the space characters, the punctuation and the case.
    New in version 19
    Ends with: ~~]: Ends with while ignoring the space characters, the punctuation and the case.
    Ends with: ~~]: Ends with while ignoring the space characters, the punctuation and the 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):
  • It at least one of the strings is a buffer, all the strings are converted into buffers and the operation is performed with buffers,
  • If the first condition is not fulfilled, if at least one of the strings in in Unicode format, all the strings are converted into 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 following conversion rule is used for the Unicode systems (Windows CE):
  • It at least one of the strings is a buffer, all the strings are converted into buffers and the operation is performed with buffers,
  • Otherwise, the operation is performed in Unicode.
See WINDEV and the Unicode format for more details.
Reports and QueriesWindows

Comparing instances of structures and instances of classes

The dynamic structures are instantiated when they are allocated.
You have the ability to compare instances of dynamic structures (or instances of dynamic classes) via the "=" operator.
Example:
// Declare the structures
O is ST1
P is ST2
 
// Declare and instantiate the dynamic structures
P1 is dynamic Structure ST1
P1 = O
P2 is dynamic Structure ST2
P2 = O
 
// Comparison
IF P1 = P2 THEN...
The same operation can be performed on the instances of classes in order to find out whether two variables designate a single class instance.
The comparison between two different instances of a class can be performed by using buffers.
Example:
Object1 is dynamic Class1
Object2 is dynamic Class2
BufferObject1, BufferObject2 are Buffers
 
Object1 = new Class1
Object2 = new Class2
 
Serialize(Object1, BufferObject1, psdBinary)
Serialize(Object2, BufferObject2, psdBinary)
 
IF BufferObject1 = BufferObject2 THEN
// True if the two instances have identical contents
ELSE
// False if at least one member is different
END

IN operator

The IN operator is used to compare a value to a list of values. Its evaluation returns a boolean.
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.
MyValue is int
MyOtherValue is int
MyResult is boolean
MyValue = 10
MyOtherValue = 15
MyResult = (MyValue IN(1,4,6,10,MyOtherValue))
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment