The BirtComp class provides functions to compare values, for example, to test if a value is equal to, greater than, or less than another value. All the functions return either true or false. This class is static. The application cannot create instances of the class.
This function tests if a value or values is found in a field.
Syntax
Parameters
source
The field that contains the values to compare to.
target
The value or values to find in source.
Returns
True if a target value matches a value in source; returns false otherwise.
Examples
The following example tests if Canada, Mexico, or USA are values in the Country field. If any one of the countries is in the field, the function returns true.
The following example tests if Jan 15, 2009 or Jan 31, 2009 are values in the payDate field:
The following example tests if two specific product codes are values in the productCode field. If either value appears in the field, the string Obsolete is displayed; otherwise the productCode value is displayed as it appears in the field.
displayString = "Obsolete"
This function tests if a value is between two specified values.
Syntax
Parameters
source
The value to test.
target1
The first value in the range of values to compare to.
target2
The second value in the range of values to compare to.
Returns
True if the source value is between the target1 and target values; returns false otherwise.
Examples
The following expressions test field values to see if they are within a specified range of values:
The following example calculates shipment dates. If an OrderDate value is in December 2008 (between 12/01/08 and 12/31/08), add 5 days to the OrderDate value. If an OrderDate value is in a month other than December, add 3 days to the OrderDate value.
shipDate = BirtDateTime.addDay( row["OrderDate"], 5 )
ShipDate = BirtDateTime.addDay( row["OrderDate"], 3 )
This function tests if a string value matches another string value, given specified conditions.
Syntax
Parameters
source1
The first string value to use in the comparison.
source2
The second string value to use in the comparison.
ignoreCase
Specify true to perform a case-insensitive comparison. Specify false to perform a case-sensitive comparison.
trim
Specify true to remove any leading or trailing blanks before comparing the two values. Blanks in the middle of a string are not removed. Specify false if you want the comparison to include leading or trailing blanks.
Returns
True if the source1 value matches the source2 value; returns false otherwise.
Examples
The following expressions compare strings with different conditions specified:
This function tests if a value is equal to another value.
Syntax
Parameters
source
The first value to use in the comparison.
target
The second value to use in the comparison.
Returns
True if the source value is equal to the target value; returns false otherwise.
Examples
The following expressions test field values to see if they are equal to specified values:
This function tests if a value is greater than or equal to another value.
Syntax
Parameters
source
The first value to use in the comparison.
target
The second value to use in the comparison.
Returns
True if the source value is greater than or equal to the target value; returns false otherwise.
Examples
The following expressions test field values to see if they are greater than or equal to specified values:
This function tests if a value is greater than another value.
Syntax
Parameters
source
The first value to use in the comparison.
target
The second value to use in the comparison.
Returns
True if the source value is greater than the target value; returns false otherwise.
Examples
The following expressions test field values to see if they are greater than specified values:
This function tests if a value is less than or equal to another value.
Syntax
Parameters
source
The first value to use in the comparison.
target
The second value to use in the comparison.
Returns
True if the source value is less than or equal to the target value; returns false otherwise.
Examples
The following expressions test field values to see if they are less than or equal to specified values:
This function tests if a value is less than another value.
Syntax
Parameters
source
The first value to use in the comparison.
target
The second value to use in the comparison.
Returns
True if the source value is less than the target value; returns false otherwise.
Examples
The following expressions test field values to see if they are less than specified values:
This function tests if a string value matches a pattern. The pattern must use SQL pattern-matching syntax.
Syntax
Parameters
source
The string value to evaluate.
target
The string pattern to match. You must enclose the pattern in double quotation marks (" "). Use the correct case when typing the characters that you want to match. You can use the following special character in a pattern:
To match a literal percent (%) or underscore (_) character, precede those characters with two backslash (\\) characters. For example, to match S_10, use the following pattern:
To match 50%, use the following pattern:
Returns
True if the source value matches the target value; returns false otherwise.
Examples
The following example returns true for values in the productCode field that start with S18:
The following example returns true for productName values that contain the substring Ford preceded by a single character:
This function tests if a string value matches a pattern. The pattern must use JavaScript regular expression syntax.
Syntax
Parameters
source
The string value to evaluate.
target
The string pattern to match. In JavaScript regular expression syntax, you specify a pattern within a pair of forward slash (/) characters. You can use any special character supported by JavaScript regular expressions, such as the following:
To match a special character literally, precede the special character with a backslash (\) characters. For example, to match S*10, use the following pattern:
To match 50%, use the following pattern:
Returns
True if the source value matches the target value; returns false otherwise.
Examples
The following example returns true for values in the productCode field that start with S18:
The following example returns true for productName values that contain the substring Ford:
This function tests if a value is not between two specified values.
Syntax
Parameters
source
The value to test.
target1
The first value in the range of values to compare to.
target2
The second value in the range of values to compare to.
Returns
True if the source value is not between the target1 and target values; returns false otherwise.
Examples
The following expressions test field values to see if they are outside a specified range of values:
The following example calculates shipment dates. If an OrderDate value is not in December 2008 (not between 12/01/08 and 12/31/08), add 3 days to the OrderDate value. If an OrderDate value is in December, add 5days to the OrderDate value.
shipDate = BirtDateTime.addDay( row["OrderDate"], 3 )
ShipDate = BirtDateTime.addDay( row["OrderDate"], 5 )
This function tests if a value is not equal to another value.
Syntax
Parameters
source
The first value to use in the comparison.
target
The second value to use in the comparison.
Returns
True if the source value is not equal to the target value; returns false otherwise.
Examples
The following expressions test field values to see if they are not equal to specified values:
This function tests if a string value matches a pattern. The pattern must use SQL pattern-matching syntax.
Syntax
Parameters
source
The string value to evaluate.
target
The string pattern to match. You must enclose the pattern in double quotation marks (" "). Use the correct case when typing the characters that you want to match. You can use the following special character in a pattern:
To match a literal percent (%) or underscore (_) character, precede those characters with two backslash (\\) characters. For example, to match S_10, use the following pattern:
To match 50%, use the following pattern:
Returns
True if the source value does not match the target value; returns false otherwise.
Examples
The following example returns false for values in the productCode field that start with S18:
The following example returns false for productName values that contain the substring Ford preceded by a single character: