Harbour All Functions – H

HardCR

HBClass()

HB_ANSITOOEM()

hb_At

hb_cdpSelect

HB_ColorIndex

HB_DiskSpace

HB_EOL

HB_FEof

hb_FLock

hb_FUnlock

hb_gcAll
hb_gcAlloc
hb_gcCollectAll
hb_gcFree
hb_gcItemRef

hb_GetEnv

hb_HAllocate

hb_Hash
hb_HAutoAdd
hb_HBinary
hb_HCaseMatch
hb_HClone
hb_HCopy
hb_HDefault
hb_HDel
hb_HDelAt
hb_HEval
hb_HFill
hb_HGet
hb_HGetDef
hb_HHasKey
hb_HKeyAt
hb_HKeys
hb_HMerge
hb_HPairAt
hb_HPos
hb_HScan
hb_HSet

hb_HSetAutoAdd()
hb_HSetBinary() 
hb_HSetCaseMatch()

hb_HSort
hb_HValueAt
hb_HValues

hb_idleAdd
hb_idleDel
hb_idleState

hb_inetAddress
hb_inetCleanup
hb_inetClearError
hb_inetClearPeriodCallback
hb_inetClearTimeLimit
hb_inetClearTimeout
hb_inetClose
hb_inetConnect
hb_inetConnectIP
hb_inetCount
hb_inetCreate
hb_inetCRLF
hb_inetDataReady
hb_inetDGram
hb_inetDGramBind
hb_inetDGramRecv
hb_inetDGramSend
hb_inetErrorCode
hb_inetErrorDesc
hb_inetFD
hb_inetGetAlias
hb_inetGetHosts
hb_inetGetRcvBufSize
hb_inetGetSndBufSize
hb_inetInit
hb_inetIsSocket
hb_inetPeriodCallback
hb_inetPort
hb_inetRecv
hb_inetRecvAll
hb_inetRecvEndblock
hb_inetRecvLine
hb_inetSend
hb_inetSendAll
hb_inetServer
hb_inetSetRcvBufSize
hb_inetSetSndBufSize
hb_inetstatus
hb_inetTimeLimit
hb_inetTimeout

HB_IsByRef()

hb_keyPut

hb_langErrMsg
hb_langMessage
hb_langName
hb_langSelect

hb_mathErBlock
hb_mathErMode
hb_mathGetErrMode
hb_mathGetHandler
hb_mathGetLastError
hb_mathIsMathErr
hb_mathResetError
hb_mathSetErrMode
hb_mathSetHandler

hb_MemoRead
hb_MemoWrit

hb_RAt

hb_PIsByRef

hb_PValue

hb_SetKeyCheck
hb_SetKeyGet
hb_SetKeySave

hb_setListenerAdd

hb_setListenerNotify
hb_setListenerRemove

hb_SetMacro

hb_Translate

hb_ValToStr

Header

HexaToDec

Harbour Hash Functions

hb_HAllocate
hb_Hash
hb_HAutoAdd
hb_HBinary
hb_HCaseMatch
hb_HClone
hb_HCopy
hb_HDefault
hb_HDel
hb_HDelAt
hb_HEval
hb_HFill
hb_HGet
hb_HGetDef
hb_HHasKey
hb_HKeyAt
hb_HKeys
hb_HMerge
hb_HPairAt
hb_HPos
hb_HScan
hb_HSet

hb_HSetAutoAdd()
hb_HSetBinary() 
hb_HSetCaseMatch()
hb_HSort
hb_HValueAt
hb_HValues

hb_HScan()

HB_HSCAN()

Scans a hash table

Syntax

      HB_HSCAN( <hsTable>, <Value>, [<nStart>], [<nCount>, [<lExact>] )
                -> nPosition

Arguments

<hsTable> a hash table, created by HB_HASH()

<Value> to be located within the hash table

<nStart> starting index, defaults to 1 if omitted

<nCount> counter, defaults to (length) – <nStart> is omitted

<lExact> logical valuye indicating whether the comparision is to be be exact or not

Returns

The position of the located value within the hash table, or zero (0) if not found.

Compliance

Harbour

Hash Details – 2


( GET / SET Functions )

HB_HGET() : Returns a hash value

Syntax :   HB_HGET( <hsTable>, <Key> ) -> <Value>

HB_HPOS() : Locates the index of a key within a hash table

Syntax :      HB_HPOS( <hsTable>, <Key> ) -> nPosition

HB_HVALUEAT() : Gets/sets a hash value at a given position

Syntax :      HB_HVALUEAT( <hsTable>, <nPosition>, [<NewValue>] ) -> <Value>

HB_HVALUES() : Returns an array of the values of a hash table

Syntax :      HB_HVALUES( <hsTable> ) -> <aValues>

HB_HKEYAT() : Gets a hash table key at a given position

Syntax :      HB_HKEYAT( <hsTable>, <nPosition> ) -> <Key>

HB_HKEYS() : Returns an array of the keys of a hash table

Syntax :      HB_HKEYS( <hsTable> ) -> <aKeys>

HB_HPAIRAT() : Returns a two-dimensional array of a hash table entry key/value pair

Syntax :      HB_HPAIRAT( <hsTable>, <nPosition> ) -> <aKeyValue>

HB_HSCAN() : Scans a hash table for a value

Syntax :  HB_HSCAN( <hsTable>, <Value>, [<nStart>], [<nCount>, [<lExact>] ) -> nPosition

HB_HSET() : Sets a hash value

Syntax :      HB_HSET( <hsTable>, <Key>, <Value> ) -> <hsTable>

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

/*

Hash Details - 2

 ( GET / SET Funtions )

*/
#define xTrim( x ) IF( HB_ISNUMERIC( x ), LTRIM( STR( x ) ), ALLTRIM( x ) )
PROCEDURE Main()
   SetMode( 60, 120 )

   SET COLO TO "W/B"

   cLMarj := SPACE( 3 )

   CLS

   hFruits := { "apple" => "green",;
                "chery" => "pink",; 
                "apricot" => "yellow",;
                "orange" => "orange" }

   ListHash( hFruits, "Fruits" )

   * HB_HGET( <hsTable>, <Key> ) -> <Value>

   ? "Value found by literal of 'apple' : ",; 
      hFruits[ "apple" ] // green
   ? "Value found by function of 'apple' : ",; 
      HB_HGET( hFruits, "apple" ) // green
   ?

   * HB_HSET( <hsTable>, <Key>, <Value> ) -> <hsTable>
   hFruits[ "apple" ] := "red"
   ? "New (assigned literally) Value of 'apple' : ",; 
     hFruits[ "apple" ] // red

   HB_HSET( hFruits, "apple", "yellow" )
   ? "Newer (assigned by function) Value of 'apple' : ",; 
     hFruits[ "apple" ] // yellow
   ? 

   * HB_HPOS( <hsTable>, <Key> ) -> nPosition
   ? "Position of 'apple' : ", ;
     xTrim( HB_HPOS( hFruits, "apple" ) ) // 1
   * HB_HVALUEAT( <hsTable>, <nPosition>, [<NewValue>] ) -> <Value>
   ? "Position of 'melon' : ", ;
      xTrim( HB_HPOS( hFruits, "melon" ) ) // 0
   nPos := HB_HPOS( hFruits, "apricot" )
   ? "Position of 'apricot' : ",; 
     xTrim( HB_HPOS( hFruits, "apricot" ) ) // 4
   ?
   ? "Value of ", xTrim( nPos ) + ".th position :", ;
   HB_HVALUEAT( hFruits, nPos ) // yellow
   ?
   HB_HVALUEAT( hFruits, nPos, "fushia" ) 

   ? "Changed value in this position :",; 
   HB_HVALUEAT( hFruits, nPos ) // fushia
   ? 

   * HB_HKEYAT( <hsTable>, <nPosition> ) -> <Key>
   ? "Key in this position :" ,; 
     HB_HKEYAT( hFruits, nPos ) // apricot
   ?

   * HB_HKEYS( <hsTable> ) -> <aKeys>

   aKeys := HB_HKEYS( hFruits ) 

   ? "All keys in 'hFruits' : "
   AEVAL( aKeys, { | cKey | QQOUT( cKey, '' ) } ) 
                    // apple chery orange apricot
   ?

   * HB_HVALUES( <hsTable> ) -> <aValues>
   aValues := HB_HVALUES( hFruits ) 

   ? "All values in 'hFruits' : "
   AEVAL( aValues, { | cValue | QQOUT( cValue, '' ) } ) 
                     // green pink orange yellow
   ?

   * HB_HPAIRAT( <hsTable>, <nPosition> ) -> <aKeyValue>

   ? "All pairs in 'hFruits' : "

   Note : Compare this loop with below ListHash()

   FOR nPos := 1 TO LEN( hFruits )
      aKey_Value := HB_HPAIRAT( hFruits, nPos ) 
      ? xTrim( nPos ), aKey_Value[ 1 ], "=>", aKey_Value[ 2 ]
   NEXT
   ?

   * HB_HSCAN( <hsTable>, <Value>, [<nStart>], [<nCount>, [<lExact>] ) 
   *                                                     -> nPosition
   ? "Position found by scanning value 'pink' : ",;
   xTrim( HB_HSCAN( hFruits, "pink" ) ) // 2
   ?
   @ MAXROW(), 0
   WAIT "EOF HashDetails-2.prg"

RETURN // HashDetails-2.Main()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
PROCEDURE ListHash( hHash, cComment )

 LOCAL x1Pair

   cComment := IF( HB_ISNIL( cComment ), '', cComment )

   ? cComment, '' 
   * ?? "-- Type :", VALTYPE( hHash ),'' 
   * ?? "size:", NTrim ( LEN( hHash ) ) 
   ?
   FOR EACH x1Pair IN hHash
      nIndex := x1Pair:__ENUMINDEX()
      x1Key := x1Pair:__ENUMKEY()
      x1Value := x1Pair:__ENUMVALUE()
      ? cLMarj, xTrim( nIndex ) 
      * ?? '', VALTYPE( x1Pair )
      ?? '', xTrim( x1Key ), "=>"
      * ?? '', VALTYPE( x1Key ) 
      * ?? VALTYPE( x1Value ) 
      IF HB_ISARRAY( x1Value ) 
        AEVAL( x1Value, { | x1 | QQOUT( '', x1 ) } )
      ELSE 
        ?? '', xTrim( x1Value )
      ENDIF 
   NEXT

   ? REPL( "~", 32 ) 

RETURN // ListHash()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
hashdets-2