Toggle exact matches for character strings


      SET EXACT on | OFF | <xlToggle>


ON enforces exact comparison of character strings including length.

OFF resumes normal character string comparison.

<xlToggle> is a logical expression that must be enclosed in parentheses. A value of true (.T.) is the same as ON, and a value of false (.F.) is the same as OFF.


SET EXACT determines how two character strings are compared using the relational operators (=, >, <, =>, =<). When EXACT is OFF, strings are compared according to the following rules. assume two character strings cLeft and cRight where the expression to test is (cLeft = cRight):

. If cRight is a null string (“”), return true (.T.).

. If LEN(cRight) is greater than LEN(cLeft), return false (.F.).

. Otherwise, compare all characters in cRight with cLeft. If all characters in cRight equal cLeft, return true (.T.); otherwise, return false (.F.).

With EXACT ON, all relational operators except the double equal operator (==) treat two strings as equal, if they match exactly, excluding trailing spaces. With the double equal operator (==), all characters in the string are significant, including trailing spaces.

SET EXACT is a compatibility command and not recommended.


. Compatibility: In Harbour, unlike other dialects, SET EXACT has no affect on operations other than relational operators. This includes the SEEK and FIND commands. If you need to seek exact matches of character keys, use the example user-defined function SeekExact() in the SEEK command reference.


      .  These examples show various results of the equal operator (=)
         with SET EXACT:

      ? "123" = "12345"            // Result: .F.
      ? "12345" = "123"            // Result: .T.
      ? "123" = ""                 // Result: .T.
      ? "" = "123"                 // Result: .F.
      ? "123" = "123  "            // Result: .F.
      ? "123" = "12345"            // Result: .F.
      ? "12345" = "123"            // Result: .F.
      ? "123" = ""                 // Result: .F.
      ? "" = "123"                 // Result: .F.
      ? "123" = "123  "            // Result: .T.


SEEK, Operators

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.