FWH1905: FW_StrICmp(): Case Insensitive Comparison

FWH1905: FW_StrICmp(): Case Insensitive Comparison

Postby nageswaragunupudi » 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:
Code: Select all  Expand view

Upper( c1 ) == Upper( c2 )
 

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:
Code: Select all  Expand view

FW_STRICMP( c1, cOperator, c2, [lExact] ) --> lTrue
 


Usage:
Code: Select all  Expand view

SET EXACT OFF
? FW_STRICMP( "FiveTech Software", "=" "FIVETECH" ) --> .t.
? FW_STRICMP( "FiveTech Software", "==" "fivetech" ) --> .f.
? FW_STRICMP( "FiveTech Software", "=" "FIVETECH", .t. ) --> .f.
 


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.
Code: Select all  Expand view

FW_STRICMP( "aaa", "AAA" ) //--> 0
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 96 guests