FWH1905: FW_StrICmp(): Case Insensitive Comparison
Posted: Wed Jun 26, 2019 4:06 pm
In most cases, when we compare strings, we need to convert both of them to upper or lower case before comparison.
Eg:
Converting the strings to upper or lower case every time adds overhead to the application.
FW_StrICmp() avoids the need for this conversion and gives exactly the same results as the normal coparison.
Syntax-1:
Usage:
We can use all other comparison operators like >, <, >=, <=, <>, !=. Comparison respects the current setting of SET EXACT, which can be overridden by the last parameter. In all cases, the results are identical to normal comparison with case conversion.
Syntax-2:
FW_STRICMP( c1, c2, [lExact] ) --> nResult, which can be -1, 0, 1 meaning less than, equal to, greater than.
Eg:
Code: Select all
Upper( c1 ) == Upper( c2 )
FW_StrICmp() avoids the need for this conversion and gives exactly the same results as the normal coparison.
Syntax-1:
Code: Select all
FW_STRICMP( c1, cOperator, c2, [lExact] ) --> lTrue
Code: Select all
SET EXACT OFF
? FW_STRICMP( "FiveTech Software", "=" "FIVETECH" ) --> .t.
? FW_STRICMP( "FiveTech Software", "==" "fivetech" ) --> .f.
? FW_STRICMP( "FiveTech Software", "=" "FIVETECH", .t. ) --> .f.
Syntax-2:
FW_STRICMP( c1, c2, [lExact] ) --> nResult, which can be -1, 0, 1 meaning less than, equal to, greater than.
Code: Select all
FW_STRICMP( "aaa", "AAA" ) //--> 0