Test Functions
A test function performs data comparisons. Use a test function to identify the data type of a value, or determine if a value exists. You can use a test function on all data types.
CompareDictionary
CompareDictionary(a,b)
: Compares 2 strings ignoring case differences, and compares text that appears to consist of numbers, in numerical order. The function returns -1 if a < b, 0 if a==b, and 1 if a > b.
This function is not exactly in the same order as a dictionary compare, in that it does not handle diacritical marks the same way the Sort tool does when configured to do a dictionary sort using the conventions of a particular language.
Example
CompareDictionary("apples","bananas")
returns -1.
CompareDictionary("APPLES","bananas")
returns -1.
CompareDictionary("apples","BANANAS")
returns -1.
CompareDictionary("Cherries","Bananas")
returns 1.
CompareDictionary("Bananas","bananas")
returns 0.
CompareDictionary("2","10")
returns -1 (2 is less than 10, even though the character '2' is greater than the character '1').
CompareDictionary("minus -2","minus -10")
returns 1 (-2 is greater than -10. Minus signs are only recognized at the beginning or after white space).
CompareDictionary("minus-2","minus-10")
returns -1 (2 is less than 10. The minus sign, not being after a space, was not counted as part of the number).
CompareDictionary("pi 3.14","pi 6.28e-1")
returns 1 (Yes, it recognizes floating-point number syntax, and 3.14 is greater than 0.628).
CompareDictionary("12.00","12.0")
returns 1 (When numbers have the same value, the longer string of digits is considered greater).
CompareDictionary("a", "À")
returns -1.
CompareDictionary("n","ñ")
returns -1 (letters with marks are larger in the Latin alphabet than all the unmarked letters).
CompareDictionary("o","ñ")
returns -1 (In a Spanish Dictionary compare the Ñ should be less than O. This is not a linguistic dictionary comparison).
CompareDictionary("ñ","Ñ")
returns 0 (marked characters compare ignoring case, too).
CompareDigits
CompareDigits(a, b, nNumDigits)
: Compares 2 numbers and determines if they are the same to the given number of digits (nNumDigits).
The comparison finds the difference between the numbers and reports A and B the same when the leading digit of the difference is nNumDigits or more places to the right of the digits of the larger of A and B.
The nNumDigits
parameter must not be null and must be between 1 and 19. Otherwise, an error occurs. If a non-integer is given, it's rounded to the nearest integer (nNumDigits can be between 0.5 and 19.499).
Example
CompareDigits(12345, 12444, 3)
returns "True" (because the difference is 99, and its leading digit is 3 places to the right of the leading digit of A).
CompareDigits(12345, 12445, 3)
returns "False" (because the difference is 100, and its leading digit is only 2 places to the right of the leading digit of A).
CompareDigits(12.345, 12.347, 3)
returns "True" (because the difference is 0.002, and its leading digit is 4 places to the right of the leading digit of A).
CompareDigits(12.345, 12.435, 3)
returns "True" (because the difference is 0.09, and its leading digit is 3 places to the right of the leading digit of A).
CompareDigits( .91234, .91334, 3)
returns "False" (because the difference is .001, and its leading digit is only 2 places to the right of the leading digit of A).
CompareEpsilon
CompareEpsilon(a, b, epsilon)
: Compares 2 floating-point numbers and returns True if they are within epsilon.
Example
CompareEpsilon(123.456789101112, 123.456789101114, 0.0001)
returns "True."
CompareEpsilon(123.456, 123.456789101112, 0.0001)
returns "False."
EqualStrings
EqualStrings(a,b)
: Compares string (a) to string (b) to determine if they are an exact match. The function returns True if all characters in both a and b are identical and False if 1 or more characters are not identical.
Note that this function is case-sensitive.
Example
EqualStrings('Hello','Hello')
returns True.
EqualStrings('Hello','hello')
returns False.
EqualStrings('happy birthday','happy birthday')
returns True.
EqualStrings('happy birthday','happy birthday')
returns False.
EqualStrings('Happy 10th birthday!', 'Happy 10th birthday')
returns False.
EqualStrings('Hello','')
returns False.
EqualStrings('Hello', Null)
returns False.
EqualStrings(Null(), Null())
returns True.
EqualStrings('Hello')
returns an error. The function requires exactly 2 parameters.
IsEmpty
IsEmpty(v)
: Tests if v is NULL or equal to "".
Example
Name (v) | IsEmpty |
---|---|
John | False |
True | |
Mary | False |
[Null] | True |
IsInteger
IsInteger(v)
: Tests if (v) contains a value that can be converted to an integer. If so, it returns True.
Section
Value (v) | IsInteger |
---|---|
1 | True |
1.23 | False |
B | False |
IsLowerCase
IsLowerCase(String)
: Returns True if all (1 or more) alphabetic characters in a string are lowercase and False if one or more alphabetic characters are uppercase. The function ignores non-alphabetic characters. Note that this function only applies to characters with a case distinction and might not apply to characters in all languages.
This function works with string data types only.
This function returns True only if there is at least one lowercase character and no uppercase characters.
This function returns True only for characters that have a case distinction. It might not be applicable to characters in all languages (for example, Japanese).
If you pass in numeric data as a string, the function returns False because, in this case, there are no alphabetic characters to evaluate. The string must contain at least 1 alphabetic character for the function to evaluate it as lowercase.
This function ignores spaces as they are non-alphabetic characters. If the expression contains only spaces, it evaluates as False because spaces don't have a case distinction.
If you pass in a Null value, the function returns False.
Example
IsLowerCase('nicole')
returns True.
IsLowerCase('happy birthday!')
returns True.
IsLowerCase('niCOLE')
returns False.
IsLowerCase('2023')
returns False. The function ignores non-alphabetic characters, so it evaluates this value as an empty field, for example: ('').
IsLowerCase(nicole)
returns an error.
IsLowerCase(2023)
returns an error.
IsLowerCase(null)
returns False.
IsLowerCase(' ')
returns False. Spaces don't have a case distinction.
IsNull
IsNull(v)
: Tests if (v) is NULL. Returns True if v is NULL, otherwise returns False.
To populate a row with a NULL value, use the NULL()
function.
Example
Name (v) | IsNull |
---|---|
John | False |
[Null] | True |
Mary | False |
IsNumber
IsNumber(v)
: Tests if the field type for (v) is a number or not.
IsSpatialObj
IsSpatialObj(v)
: Tests if the field type for (v) is a spatial object or not.
IsString
IsString(v)
: Tests if the field type for (v) is a string or not.
IsUpperCase
IsUpperCase(String)
: Returns True if all (1 or more) alphabetic characters in a string are uppercase and False if one or more alphabetic characters are lowercase. The function ignores non-alphabetic characters. Note that this function only applies to characters with a case distinction and might not apply to characters in all languages.
This function works with string data types only.
This function returns True only if there is at least one uppercase character and no lowercase characters.
This function returns True only for characters that have a case distinction. It might not be applicable to characters in all languages (for example, Japanese).
If you pass in numeric data as a string, the function returns False because, in this case, there are no alphabetic characters to evaluate. The string must contain at least 1 alphabetic character for the function to evaluate it as uppercase.
This function ignores spaces as they are non-alphabetic characters. If the expression contains only spaces, it evaluates as False because spaces don't have a case distinction.
If you pass in a Null value, the function returns False.
Example
IsUpperCase('NICOLE')
returns True.
IsUpperCase('HAPPY BIRTHDAY!')
returns True.
IsUpperCase('NicOLE')
returns False.
IsUpperCase('2023')
returns False. The function ignores non-alphabetic characters, so it evaluates this value as an empty field, for example: ('').
IsUpperCase(NICOLE)
returns an error.
IsUpperCase(2023)
returns an error.
IsUpperCase(null)
returns False.
IsUpperCase(' ')
returns False. Spaces don't have a case distinction.