ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage syntax / Operators
  • 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
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
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.
Details

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:
Memo indexing
WEBDEV - Browser code The comparison takes into account the accented lowercase characters in Browser code.
WEBDEV - Browser code The "Very loose equality" operator is not available in browser code.
"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 ...
      AndroidJava 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.
For more details on Unicode, see WINDEV and the Unicode format.
WINDEVWEBDEV - Server codeReports and QueriesWindowsLinuxAndroidAndroid Widget iPhone/iPadApple WatchJavaUser code (UMC)PHP

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.
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))

Java This feature is not available.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 10/04/2024

Send a report | Local help