Compares two values using the indicated relational operator ('=', '>', '>=', '<', '<=', '<>', 'like') which can be dynamic (for example, entered by the end user at runtime).
Compare(<value1>,<operator>,<value2>)
Where:
<value1>
Is an attribute, variable, or fixed value.
<operator>
Is a specific value of the predefined CompareKind Enumerated Domain.
<value2>
Is an attribute, variable or fixed value.
Type returned:
Boolean
Objects: Procedure, Transaction, Web Panel, Panel, Data Provider
Generators:
.NET,
.NET Framework,
Java, Apple, Android, Angular
To compare two values using the operator entered by the end user at runtime, you may define filters (for example, Conditions) as follows:
Compare(&value1,&operator &value2); //&operator is a variable based on the CompareKind Enumerated domain. It's included in the screen and entered by the end user.
CompareKind is a predefined Enumerated Domain, whose Enum Values are:
CompareKind
{
.Equal - '='
.Greater - '>'
.GreaterOrEqual -'>='
.Less - '<'
.LessOrEqual - '<='
.NotEqual -'<>'
.Like -'like'
}
You can use the function anywhere an expression is supported.
- If the operator value entered by the end user at runtime is not valid, the value used is =.
- Performing this construction at runtime is the same as writing the operator to send the SQL statements to the DBMS.
- The like operator only makes sense for Character types and their variants. If you use it for other data types, it may give an execution error depending on whether the DBMS / version supports it or not.
Consider the following Transaction object:
Product
{
ProductId*
ProductName
ProductPrice
}
Also, consider the 'ProducList' Web Panel object whose Web Layout, Variables, and Conditions are shown below:

&ProductId - Data type based on Attribute: ProductId
&ProductName - Data type based on Attribute: ProductName
&ProductPrice - Data type based on Attribute: ProductPrice
&Op1 - Data type CompareKind, GeneXus
&Op2 - Data type CompareKind, GeneXus
&Op3 - Data type CompareKind, GeneXus
Compare(ProductId, &Op1, &ProductId)
when not &ProductId.IsEmpty();
Compare(ProductName, &Op2, &ProductName)
when not &ProductName.IsEmpty();
Compare(ProductPrice, &Op3, &ProductPrice)
when not &ProductPrice.IsEmpty();
At runtime, when executing the 'ProducList' Web Panel object, the end user can select a predefined operator value for &Op1, &Op2, and/or &Op3.

For example, if the end user selects Greater for the &op3 variable and enters 9 for the &ProductPrice variable, only products with a price greater than 9 will be displayed in the Grid:

Operators