xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HSetCaseMatch()

Changes the case sensitivity attribute of a hash.

Syntax

HSetCaseMatch( <hHash>, <lOnOff> ) --> hHash

Arguments

<hHash>
A variable referencing the hash whose case sensitivity attribute is changed.
<lOnOff>
A logical value. .T. (true) enables case sensitivity of a hash, and .F. (false) disables it.

Return

The function returns a reference to <hHash>.

Description

The function changes an attribute of a hash that identifies whether or not character string matching for keys is case sensitive. By default, this attribute is .T. (true) when a new hash is created. This causes keys consisting of character strings that differ only in case can be assigned different values.

Use function HGetCaseMatch() to retrieve the current setting of this attribute.

Info

See also:Hash(), HGetAutoAdd(), HGetCaseMatch(), HSetAutoAdd()
Category: Hash functions , xHarbour extensions
Source:vm\hash.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates case sensitivity of keys in a
// new created hash and outlines the effect of changing
// the case sensitivity attribute in a populated hash.

   PROCEDURE Main
      // create an empty hash
      LOCAL hHash := {=>}

      ? HGetCaseMatch( hHash )          // result: .T.

      // Populating the hash:
      hHash[ 'KEY'  ] := 'UPPER CASE'
      hHash[ 'key'  ] := 'lower case'
      hHash[ 'Key'  ] := 'Mixed Case'

      ? Len( hHash )                    // result: 3

      ? hHash[ 'KEY' ]                  // result: UPPER CASE
      ? hHash[ 'key' ]                  // result: lower case
      ? hHash[ 'Key' ]                  // result: Mixed Case

      // Don't do this with a populated case sensitive hash
      HSetCaseMatch( hHash, .F. )

      ? hHash[ 'KEY' ]                  // result: Mixed Case
      ? hHash[ 'key' ]                  // result: Mixed Case
      ? hHash[ 'Key' ]                  // result: Mixed Case
   RETURN

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