FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FWH1905: FW_StrICmp(): Case Insensitive Comparison
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
FWH1905: FW_StrICmp(): Case Insensitive Comparison
Posted: Wed Jun 26, 2019 04: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 (fw): Select all Collapse
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 (fw): Select all Collapse
FW_STRICMP( c1, cOperator, c2, [lExact] ) --> lTrue


Usage:
Code (fw): Select all Collapse
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 (fw): Select all Collapse
FW_STRICMP( "aaa", "AAA" ) //--> 0
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion