Hello Viktor, 


> Very strange name for a function. Can you describe what it does?
> 

Text taken from the manual xharbour:



> HSetAACompatibility()
> Enables or disables associative array compatibility for an empty hash. 
> Syntax
> HSetAACompatibility( <hHash>, <lToggle> ) --> lSuccess
> 
> Arguments
> <hHash> 
> This is a variable referencing an empty hash. If the hash is not empty, a
> runtime error is raised. 
> <lToggle> 
> A logical value must be passed as second parameter. .T. (true) enables
> associative array compatibility, and .F. (false) disables it. Return
> The function returns a logical value indicating success (.T.) or failure
> (.F.) of the operation. 
> Description
> The functions accepts an empty hash and toggles associative array
> compatibility. If this is switched on, values of a hash can be retrieved
> not only with the hash key, but also using their numeric ordinal position.
> Hash access can then be programmed using the array element operator and a
> numeric index. 
> Info
> See also: Array(), HaaGetKeyAt(), HaaGetPos(), HaaGetRealPos(),
> HaaGetValueAt(), HaaSetValueAt(), Hash(), HGetAACompatibility() 
> Category: Associative arrays , Hash functions , xHarbour extensions 
> Source: vm\hash.c 
> LIB: xhb.lib 
> DLL: xhbdll.dll 
> 
> Example
> // The example outlines the possibilities for accessing values
> // of a hash when associative array compatibility is switched on.
> 
>    PROCEDURE Main
>       LOCAL hArray := Hash(), aPos, nPos
> 
>       HSetAACompatibility( hArray, .T. )
>       HSetCaseMatch( hArray, .F. )
> 
>       hArray[ "One"  ] := 10
>       hArray[ "Two"  ] := 20
>       hArray[ "Three"] := 30
>       hArray[ "Four" ] := 40
>       hArray[ "Five" ] := 50
> 
>       ? hArray[1]                    // result: 10
>       ? hArray[2] += 100             // result: 120
> 
>       ? hArray:Three                 // result: 30
> 
>       ? hArray["Four"] + hArray[5]   // result: 90
>    RETURN
> 
> 
> --------------------------------------------------------------------------------
> 

...and here the source of "HASH.C" extracts:



> HB_EXPORT BOOL hb_hashSetAACompatibility( PHB_ITEM pHash, BOOL bCompatAA,
> BOOL bSilent )
> {
>    if( pHash && HB_IS_HASH( pHash ) && pHash->item.asHash.value->uiLevel
> == 0 && hb_hashLen( pHash ) == 0 )
>    {
>       PHB_BASEHASH pBaseHash = pHash->item.asHash.value;
> 
>       if( bCompatAA )
>       {
>          if( ! pBaseHash->pAccessAA )
>          {
>             pBaseHash->pAccessAA = (ULONG *) hb_xgrab( sizeof( ULONG ) *
> pBaseHash->ulAllocated );
>          }
>          return TRUE;
>       }
>       else
>       {
>          if( pBaseHash->pAccessAA )
>          {
>             hb_xfree( pBaseHash->pAccessAA );
>             pBaseHash->pAccessAA = NULL;
>          }
>          return TRUE;
>       }
>    }
>    else if( !bSilent )
>    {
>       hb_errRT_BASE( EG_ARG, 2017, NULL, "HSETAACOMPATIBILITY", 2,
>            hb_paramError( 1 ), hb_paramError( 2 ));
>    }
>    return FALSE;
> }
> 

Best regards,

Rossine.

-- 
View this message in context: 
http://www.nabble.com/Working-with-HASH%28%29-tp23034241p23038113.html
Sent from the Harbour - Dev mailing list archive at Nabble.com.

_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to