ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / Operators
  • Use
  • Rules
  • Notes
  • Numeric variable
  • String variable
  • Priority
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Logical operators
Use
The logical operators are as follows:
  • AND
Logical multiplication. The conditions made of AND are entirely evaluated (even if the first condition is false).
  • _AND_
Logical multiplication. The conditions made of _AND_ are evaluated in an optimized way. If the first part of the expression is false, the rest of the expression is not evaluated.
  • OR
Logical addition. The conditions made of OR are entirely evaluated (even if the first condition is true).
  • _OR_
Logical addition. The conditions made of _OR_ are evaluated in optimized way. If the first part of the expression is true, the rest of the expression is not evaluated.
  • NOT
Logical negation.
The logical operators are used to perform logical operations and to build conditions.
IF Customer.City = "Montpellier" AND Customer.Title = "Mr" THEN
ManMontpellier ++ // Number of men living in Montpellier
END
IF Customer.City = "Montpellier" OR Customer.City = "Lyon" THEN
MontpellierLyon ++ // Number of customers living in Montpellier,
// or in Lyon
END
Rules
True AND True: returns True
True AND False: returns False
True OR True: returns True
True OR False: returns True
NOT True: returns False
Notes

Numeric variable

If a numeric variable is handled like a logical operator (boolean), "0" is equivalent to False. Any other value is equivalent to True.
For example, the two following lines of code are equivalent:
IF TestNum THEN...
IF TestNum <> 0 THEN...
The first syntax (IF TestNum THEN) should be preferred to the second one.

String variable

A WLanguage error will occur if a string variable is handled like a logical operator.
For example, the syntax: "IF StrTest THEN" will return an error at run time (but not when the project is compiled).

Priority

The AND and OR, _AND_ and _OR_ operators have the same priority. To give priorities to these operators, all you have to do is use brackets.
For example:
IF (A = 2 AND B > 3) OR (A = 2 AND B < 0) THEN ...
Exceptions:
  • In SQL filters and queries, the AND operator takes precedence over the OR operator.
    For example:
    Condition1 AND Condition2 OR Condition3

    will be evaluated as follows:
    (Condition1 AND Condition2) OR Condition3
  • The optimized logical addition _OR_ must not be used if one of the expressions to compare is using the result of a function that may return NULL.
    For example, the following comparison:
    IF CallFunction() = "Value1" _OR_ CallFunction() = "Value2" THEN...

    will have to be replaced with the following code if CallFunction can return the NULL value:
    IF CallFunction() = "Value1" OR CallFunction() = "Value2" THEN...
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help