xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

SET EXACT

Determines the mode for character string comparison.

Syntax

SET EXACT on | OFF | ( <lOnOff> )

Arguments

on | OFF | ( <lOnOff> )
This option toggles if an exact comparison is performed with character strings. or not. The default is OFF or .F. (false), i.e. characters are compared up the length of the shorter string. To change the setting use ON or .T. (true) as parameter. The parameter can also be specified as a logical expression enclosed in parentheses.

Description

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.

Info

See also:=, ==, Set()
Category: SET commands
Source:rtl\set.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe