SET EXACT

SET EXACT*

Toggle exact matches for character strings

Syntax

      SET EXACT on | OFF | <xlToggle>

Arguments

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.

Description

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.

Notes

. 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.

Examples

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

      SET EXACT OFF
      ? "123" = "12345"            // Result: .F.
      ? "12345" = "123"            // Result: .T.
      ? "123" = ""                 // Result: .T.
      ? "" = "123"                 // Result: .F.
      ? "123" = "123  "            // Result: .F.
      //
      SET EXACT ON
      ? "123" = "12345"            // Result: .F.
      ? "12345" = "123"            // Result: .F.
      ? "123" = ""                 // Result: .F.
      ? "" = "123"                 // Result: .F.
      ? "123" = "123  "            // Result: .T.

Seealso

SEEK, Operators

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s