Return to Language Reference home pageHarbour API Explorer
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Only APIs with Curated Documentation are available from this screen.
Most API (functions) description comes from https://github.com/Petewg/harbour-core/wiki. Same content license applies.
To search all Harbour Core, Contribs and Packages APIs, including undocumented ones, go to Source Code Explorer.
Found 54 APIs
HALLOCATE => hb_HAllocate(<hHash>,<nElements>) ➔ NIL

Pre-allocates space (memory) for <nElements> hash items. It's useful when you intend to add a set of new items because you will save time spent in grabbing each new element separately; preallocating elements may improve speed execution of program.
Note:this function will not "truncate" or release (delete) items, if the <nElements> number is less than the actual item count already into the hash table.*


Hash => hb_Hash([<xKey1,Value1>],[<xKey2,Value2>],[...]) ➔ <hsTable>

Creates a hash table and, optionally, populates it with elements (pairs of keys and values).
To initialize (create) a hash table, it is recommended to do it in an inline assignment, using the literal {=>} instead of hb_Hash() function. For example: hHash := {=>} or hHash := {"key1"=>"value1"}.
Keys can be of type: string, number, date, timestamp, pointer.
Values can be of almost any type that is supported by Harbour: string, numeric, date, timestamp, logical, pointer, array, hash table, code-block, NIL.


hb_HAllocate(<hHash>,<nElements>) ➔ NIL

Pre-allocates space (memory) for <nElements> hash items. It's useful when you intend to add a set of new items because you will save time spent in grabbing each new element separately; preallocating elements may improve speed execution of program.
Note:this function will not "truncate" or release (delete) items, if the <nElements> number is less than the actual item count already into the hash table.*


hb_Hash([<xKey1,Value1>],[<xKey2,Value2>],[...]) ➔ <hsTable>

Creates a hash table and, optionally, populates it with elements (pairs of keys and values).
To initialize (create) a hash table, it is recommended to do it in an inline assignment, using the literal {=>} instead of hb_Hash() function. For example: hHash := {=>} or hHash := {"key1"=>"value1"}.
Keys can be of type: string, number, date, timestamp, pointer.
Values can be of almost any type that is supported by Harbour: string, numeric, date, timestamp, logical, pointer, array, hash table, code-block, NIL.


hb_HAutoAdd(<hHash>,[<nAutoAdd|lAutoAdd>],[<xDefault>]) ➔ <lPreviousFlag>

Sets the 'AutoAdd' flag for the hash array.
If the second parameter is not specified, this function will still return the previous setting of the 'AutoAdd' flag.

Note 1: Definition of 'AutoAdd' flag as per http://www.kresin.ru/en/hrbfaq_3.html#Doc8
AutoAdd - when set in TRUE (the default), the operation assignment ( as harr["fantasy"] := "fiction" in the above example ) leads to the addition of a new pair, while the FALSE leads to an error.

Note 2: Deprecates hb_HSetBinary() function


hb_HBinary(<hHash>,[<lFlag>]) ➔ <lPreviousFlag>

Sets the 'Binary' flag for the hash array.
If the iFlag is not specified, this function will still return the previous setting of the 'Binary' flag.

Note 1: Definition of 'Binary' flag as per http://www.kresin.ru/en/hrbfaq_3.html#Doc8
Binary - when set in TRUE (the default), sorting the array is made in accordance with the weight of the binary code of the character, without taking into account the national code pages and the relevant rules of the sort. This allows you to significantly speed up the manipulation with the hash of arrays.

Note 2: Deprecates hb_HSetBinary() function


hb_HCaseMatch(<hHash>,[<lFlag>]) ➔ <lPreviousFlag>

Sets the 'CaseMatch' flag for the hash array.
If the second parameter is not specified, this function will still return the previous setting of the 'CaseMatch' flag.

Note 1: Definition of 'CaseMatch' flag as per http://www.kresin.ru/en/hrbfaq_3.html#Doc8
CaseMatch - defines wether to take into consideration the Case character ( big/small ) for sorting or not.

Note 2: Deprecates hb_HSetCaseMatch() function


hb_HClear(<hHash>) ➔ <hHash>

Deletes all the elements in <hHash> leaving an empty hash table.


hb_HClone(<hHash>) ➔ <hsDestination>

Creates a copy of a hash table.


hb_HCopy(<hsSource>,<hsDestination>,[<nStart>],[<nCount>]) ➔ <hsDestination>

Adds entries from the source hash table to the destination hash table.


hb_HDefault(<hHash>,<DefaultValue>) ➔ <OldDefaultValye>

Sets the default value assigned to new keys in a hash table. Returns the previous default value (if any).
This function is not needed if using the hb_HAutoAdd() extended parameters.


hb_HDel(<hHash>,<xKey>) ➔ <hHash>

Deletes a key and it's associated value from a hash table.
Does not generate an error when unexciting key is passed to hb_HDel().


hb_HDelAt(<hHash>,<nPosition>) ➔ <hHash>

Removes an entry from a hash table, based on its index position.


hb_HEval(<hHash>,<bBlock>,[<nStart>],[<nCount>]) ➔ <hHash>

Evaluates a code block across the contents of a hash table. It's quite similar to AEval() function but works with hashes, instead of plain arrays.
The code block receives the key, value, and numeric position of every hash element that is being processed( e.g.: {|k,v,i| ... } )


hb_HFill(<hHash>,<Value>) ➔ <hHash>

Sets the values of all the keys of <hHash> table to <xValue>.


hb_HGet(<hHash>,<xKey>) ➔ <xValue>

Gets the value associated to a key. Use hb_HGetDef() instead of this function, to avoid Run Time Error when a value does't exists.


hb_HGetDef(<hHash>,<xKey>,[<DefaultValue>]) ➔ <xValue|NIL>

Returns either the value associated to the given key within the <hHash> hash table, or the default value <DefaultValue> if the <Key> doesn't exist. It returns NIL when both the <Key> doesn't exist and no <DefaultValue> has given.


hb_HGetRef(<hHash>,<xKey>,[<@xValue>]) ➔ <lFound>

Returns .T. if <xKey> exists. Optionally stores its associated key-value to <xValue> which must be passed by reference to retain the stored value. If the <xKey> is not found, <xValue> will become NIL.
Remark: This function, in functionality terms, might be viewed as a combination of hb_HGet() and hb_HHasKey() functions.


hb_HHasKey(<hHash>,<xKey>,[<@nPos>]) ➔ <lExists>

Returns .T. if <xKey> exists in the hash table and stores its ordinal position to @<nPos> which must be passed by reference to retain the stored position. If the key doesn't exists then <nPos> will be the position of the smaller nearest key.


hb_HKeepOrder(<hHash>,[<lKeepOrder>]) ➔ <lPrevKeepOrder>

Sets the 'KeepOrder' flag for the hash array.
If the second parameter is not specified, this function will still return the previous setting of the 'KeepOrder' flag.

Note 1: This flag controls the order by which the elements are stored in the hash table. If the `KeepOrder` flag is TRUE then the order by which the elements are created or added will be preserved. If it is FALSE, then the elements of the hash table will be sorted (other flags may affect the order such as the `Binary` flag and `CaseMatch` flags). This flag is enabled TRUE by default.

Note 2: Deprecates hb_HSetOrder() function


hb_HKeyAt(<hHash>,<nPosition>) ➔ <xKey>

Retrieves the key at a given position in a hash table. The <nPosition> value must be in the range 1...Len( hHash ). If hash table is empty or <nPosition> is zero or greater than Len( hHash ) then a "Bound error" RTE (RunTime Error) occurs .


hb_HKeys(<hHash>) ➔ <axKeys>

Returns an array with all the keys (but not the associated values) of a hash table.


hb_HMerge(<hsDestination>,<hsSource>,<bBlock|nMethod>) ➔ <hsDestination>

Merges <hsSource> hash into <hsDestination> hash. With the 3rd parameter can be optionally specified the merge mode. When source elements copied will substitute those with the same key in the destination hash table.


hb_HPairAt(<hHash>,<nPosition>,[<@xKey>],[<@xValue>]) ➔ <aKeyValue>

Will retrieve the key/value pair entry at the nPosition position of hHash, and either set the xKey and xValue parameter if specified, or return a two-dimensional array of the key/value values.


hb_HPos(<hHash>,<xKey>) ➔ <nPosition>

Returns the position of <xKey> in the hash.


hb_HScan(<hHash>,<uValue|bBlock>,[<nStart>],[<nCount>],[<lExact>]) ➔ <nPosition>

Scans the hash table values searching for <uValue>. Alternatively, you can pass a codeblock <bBlock> that receives the xKey, the value and the position of each element, and should return .T. if a match is found. The range of hash table items to be scanned can be limited by the <nStart> and <nCount> parameters, otherwise all elements are scanned. The logical flag <lExact> determines if an exact matching (or not) shall performed, when searching for strings or datetime or array or hashes.
Returns the numeric position of the located value within the hash table, or zero (0) if nothing found.


hb_HSet(<hHash>,<xKey>,<xValue>) ➔ <hHash>

Sets (or adds a new) key/value pair to <hHash> hash table.


hb_HSetDef(<hHash>,<xKey>,<xDefVal>) ➔ <xKeyValue>

This function checks if <xKey> exists and optionally sets the key-value to <xDefVal>.

  • If <xKey> does not exists then adds it to hash array and sets the key-value to <xDefVal>, if passed.
  • If <xKey> exists in hash array and <xDefVal> is given, then it checks if the type of key-value is compatible (i.e. same valtype) with <xDefVal> and if not then replaces key-value with <xDefVal>.
  • If <xKey> exists in hash array and no <xDefVal> is given, then nothing changes.

This function returns the value associated with xKey, which value (after successful function execution) can be either the initial value or the applied <xDefVal> or NIL (when a new <xKey> added while no <xDefVal> value is given). In other words this function it's a combination of hb_HGetDef() and hb_default() and works like the example PRG code, but it is **much faster!**
Note: that's a 'brand-new' function released with this 2018-01-05 14:12 commit., therefore is not available in earlier Harbour 3.2 versions (it doesn't, also, exist in Viktor's (currently archived) fork, Harbour 3.4).


hb_HSort(<hHash>) ➔ <hHash>

Sorts the hast <hHash>.The sort order depends on binary and case sensitivity hash array flags.


hb_HValueAt(<hHash>,<nPosition>,[<xNewValue>]) ➔ <xValue>

Returns the value associated to the key at a given position in a hash table or xNewValue if used to set the xValue. Optionally, you can set the new value <xNewValue> associated to the key at that position.


hb_HValues(<hHash>) ➔ <aValues>

Returns an array with all the associated xValues (not the xKeys) of a hash table.


hb_IsHash(<xExp>) ➔ <lResult>

Determines if <xExp> evaluates to a hash value (valtype "H").


hb_IsHashKey(<xExp>) ➔ <lResult>

Determines if <xExp> can be used as a hash key (valtypes "N", "D", "T", "C" and "P").


hb_IsNull(<xExp>) ➔ <lResult>

Determines if the length of <xExp>, when is a string, an array or a hash, is zero ( Len() == 0 ).


HCLONE => hb_HClone(<hHash>) ➔ <hsDestination>

Creates a copy of a hash table.


HCOPY => hb_HCopy(<hsSource>,<hsDestination>,[<nStart>],[<nCount>]) ➔ <hsDestination>

Adds entries from the source hash table to the destination hash table.


HDEFAULT => hb_HDefault(<hHash>,<DefaultValue>) ➔ <OldDefaultValye>

Sets the default value assigned to new keys in a hash table. Returns the previous default value (if any).
This function is not needed if using the hb_HAutoAdd() extended parameters.


HDEL => hb_HDel(<hHash>,<xKey>) ➔ <hHash>

Deletes a key and it's associated value from a hash table.
Does not generate an error when unexciting key is passed to hb_HDel().


HDELAT => hb_HDelAt(<hHash>,<nPosition>) ➔ <hHash>

Removes an entry from a hash table, based on its index position.


HEVAL => hb_HEval(<hHash>,<bBlock>,[<nStart>],[<nCount>]) ➔ <hHash>

Evaluates a code block across the contents of a hash table. It's quite similar to AEval() function but works with hashes, instead of plain arrays.
The code block receives the key, value, and numeric position of every hash element that is being processed( e.g.: {|k,v,i| ... } )


HFILL => hb_HFill(<hHash>,<Value>) ➔ <hHash>

Sets the values of all the keys of <hHash> table to <xValue>.


HGET => hb_HGet(<hHash>,<xKey>) ➔ <xValue>

Gets the value associated to a key. Use hb_HGetDef() instead of this function, to avoid Run Time Error when a value does't exists.


HGETCASEMATCH => hb_HCaseMatch(<hHash>,[<lFlag>]) ➔ <lPreviousFlag>

Sets the 'CaseMatch' flag for the hash array.
If the second parameter is not specified, this function will still return the previous setting of the 'CaseMatch' flag.

Note 1: Definition of 'CaseMatch' flag as per http://www.kresin.ru/en/hrbfaq_3.html#Doc8
CaseMatch - defines wether to take into consideration the Case character ( big/small ) for sorting or not.

Note 2: Deprecates hb_HSetCaseMatch() function


HGETKEYAT => hb_HKeyAt(<hHash>,<nPosition>) ➔ <xKey>

Retrieves the key at a given position in a hash table. The <nPosition> value must be in the range 1...Len( hHash ). If hash table is empty or <nPosition> is zero or greater than Len( hHash ) then a "Bound error" RTE (RunTime Error) occurs .


HGETKEYS => hb_HKeys(<hHash>) ➔ <axKeys>

Returns an array with all the keys (but not the associated values) of a hash table.


HGETPAIRAT => hb_HPairAt(<hHash>,<nPosition>,[<@xKey>],[<@xValue>]) ➔ <aKeyValue>

Will retrieve the key/value pair entry at the nPosition position of hHash, and either set the xKey and xValue parameter if specified, or return a two-dimensional array of the key/value values.


HGETPOS => hb_HPos(<hHash>,<xKey>) ➔ <nPosition>

Returns the position of <xKey> in the hash.


HGETVALUEAT => hb_HValueAt(<hHash>,<nPosition>,[<xNewValue>]) ➔ <xValue>

Returns the value associated to the key at a given position in a hash table or xNewValue if used to set the xValue. Optionally, you can set the new value <xNewValue> associated to the key at that position.


HGETVALUES => hb_HValues(<hHash>) ➔ <aValues>

Returns an array with all the associated xValues (not the xKeys) of a hash table.


HHASKEY => hb_HHasKey(<hHash>,<xKey>,[<@nPos>]) ➔ <lExists>

Returns .T. if <xKey> exists in the hash table and stores its ordinal position to @<nPos> which must be passed by reference to retain the stored position. If the key doesn't exists then <nPos> will be the position of the smaller nearest key.


HMERGE => hb_HMerge(<hsDestination>,<hsSource>,<bBlock|nMethod>) ➔ <hsDestination>

Merges <hsSource> hash into <hsDestination> hash. With the 3rd parameter can be optionally specified the merge mode. When source elements copied will substitute those with the same key in the destination hash table.


HSCAN => hb_HScan(<hHash>,<uValue|bBlock>,[<nStart>],[<nCount>],[<lExact>]) ➔ <nPosition>

Scans the hash table values searching for <uValue>. Alternatively, you can pass a codeblock <bBlock> that receives the xKey, the value and the position of each element, and should return .T. if a match is found. The range of hash table items to be scanned can be limited by the <nStart> and <nCount> parameters, otherwise all elements are scanned. The logical flag <lExact> determines if an exact matching (or not) shall performed, when searching for strings or datetime or array or hashes.
Returns the numeric position of the located value within the hash table, or zero (0) if nothing found.


HSET => hb_HSet(<hHash>,<xKey>,<xValue>) ➔ <hHash>

Sets (or adds a new) key/value pair to <hHash> hash table.


HSETVALUEAT => hb_HValueAt(<hHash>,<nPosition>,[<xNewValue>]) ➔ <xValue>

Returns the value associated to the key at a given position in a hash table or xNewValue if used to set the xValue. Optionally, you can set the new value <xNewValue> associated to the key at that position.