ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage syntax / Operators
  • Use
  • Using the default optimized mode
  • Rules
  • Notes
  • Numeric variable
  • String variable
  • Priority
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
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.
  • DANS
Corresponds to the combination of OR and '=' operators. DANS compares an element with a list of expressions. All the expressions found in the list are evaluated. For more details, see IF statement.
  • _IN_
Corresponds to the combination of OR and '=' operators. _DANS_ performs an optimized comparison of an element with a list of expressions. The expressions in the list are evaluated from left to right. Once an expression has met the condition, the rest of the expressions are not evaluated.. For more details, see IF statement.
The logical operators are used to perform logical operations and to build conditions.
IF Client.Ville = "Montpellier" AND Client.Civilité = "Monsieur" THEN
	HommeMontpellier ++	// Nombre d'hommes habitant à Montpellier
END
IF Client.Ville = "Montpellier" OR Client.Ville = "Lyon" THEN
	MontpellierLyon ++	// Nombre de clients habitant soit à Montpellier,
				// soit à Lyon
END
Using the default optimized mode
From version 2024 onwards, it is possible to use the optimized mode of the AND, OR and IN operators by default (without using the _ET_, _OR_ and _IN_ syntax)..
To do this, simply activate the "Optimization: optimized evaluation of boolean expressions (AND, OR, IN)" option in the "Compilation" tab of the project description window (see Project description: Compilation tab).
Note: This option is automatically activated in all new projects created from version 2024 onwards..
Rules
True AND True: returns True (idem _ET_)
True AND False: returns False(idem _ET_)
True OR True: returns True(idem _OU_)
True OR False: returns True(idem _OU_)
PAS 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 NumTest THEN ...
IF NumTest <> 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 ChTest THEN" will return an error at runtime (but not at compile time).

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:
SI (A = 2 ET B > 3) OU (A = 2 ET B < 0) ALORS ...
Exceptions:
  • In SQL filters and queries, the AND operator takes precedence over the OR operator.
    For example:
    Condition1 ET Condition2 OU Condition3

    will be evaluated as follows:
    (Condition1 ET Condition2) OU Condition3
  • The optimized logical addition _OR_ must not be used if one of the expressions to compare uses the result of a function that may return NULL.
    For example, the following comparison:
    SI AppelFonction() = "Valeur1" _OU_ AppelFonction() = "Valeur2" ALORS...

    will have to be replaced with the following code if CallFunction can return the NULL value:
    SI AppelFonction() = "Valeur1" OU AppelFonction() = "Valeur2" ALORS...
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/24/2024

Send a report | Local help