xHarbour Reference Documentation > Command Reference |
Determines the mode for character string comparison.
SET EXACT on | OFF | ( <lOnOff> )
The SET EXACT command determines the mode for character string comparison with the comparison operators (=, >, <, =>, =<). The following rules are applied for comparison with SET EXACT set to ON:
1) | When the right operand is a null string, the result is always .T. (true) |
2) | When the right operand is longer than the left operand, the result is always .F. (false) |
3) | When the right operand contains less or the same number of characters as the left operand, the result is only true if the left operand begins with the exact same characters as the right operand. |
With SET EXACT set to OFF, the same rules apply except that trailing spaces are ignored in the comparison.
Notes: The exact equal operator == always performs an exact comparison irrespectively of the SET EXACT setting.
Search commands and functions such as SEEK, DbSeek() or SET RELATEION are not affected by SET EXACT.
See also: | =, ==, Set() |
Category: | SET commands |
Source: | rtl\set.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates comparison results with SET EXACT PROCEDURE Main SET EXACT OFF ? "AB" = "ABCD" // result: .F. ? "ABCD" = "AB" // result: .T. ? "AB" = "" // result: .T. ? "" = "AB" // result: .F. ? "AB" = "AB " // result: .F. SET EXACT ON ? "AB" = "ABCD" // result: .F. ? "ABCD" = "AB" // result: .F. ? "AB" = "" // result: .F. ? "" = "AB" // result: .F. ? "AB" = "AB " // result: .T. ? "AB" == "AB " // result: .F. RETURN
http://www.xHarbour.com