xHarbour and hash functions

xHarbour and hash functions

Postby Otto » Fri May 29, 2020 6:38 am

Hello,
does xHarbour support hash functions?
Best regards,
Otto

Hash table
hb_Hash() Returns a hash table
hb_HAllocate() Preallocates a hash table
hb_HAutoAdd() Sets the 'auto add' flag for the hash table
hb_HBinary() Sets the 'binary' flag for the hash table
hb_HCaseMatch() Sets the 'case match' flag for the hash table
hb_HClone() Creates a copy of a hash table
hb_HCopy() Adds entries from the source hash table to the destination hash table
hb_HDefault() Returns/sets a default value for a hash table.
hb_HDel() Removes a key/value pair from a hash table
hb_HDelAt() Removes an entry from a hash table based on its index position
hb_HEval() Evaluate a code block across the contents of a hash table
hb_HFill() Fills a hash table with a value
hb_HGet() Returns a hash value
hb_HGetDef() Returns a hash value, or a default value if the key is not present
hb_HHasKey() Determines whether a hash table has an entry with a give key
hb_HKeyAt() Gets a hash table key at a given position
hb_HKeys() Returns an array of the keys of a hash table
hb_HMerge() Merges a source hash table into a destination hash table
hb_HPairAt() Returns a two-dimensional array of a hash table entry key/value pair
hb_HPos() Locates the index of a key within a hash table
hb_HScan() Scans a hash table
hb_HSet() Sets a hash value
hb_HSort() Reorganizes the internal list of the hash table to be sorted
hb_HValueAt() Gets/sets a hash value at a given position
hb_HValues() Returns an array of the values of a hash table
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: xHarbour and hash functions

Postby nageswaragunupudi » Fri May 29, 2020 7:55 am

Both Harbour and xHarbour support all these functions but with slightly different names.
hbcompat.ch provides cross translations.

Code: Select all  Expand view

#ifdef __XHARBOUR__
   /* Hash item functions */
   #xtranslate hb_Hash( [<x,...>] )            => Hash( <x> )
   #xtranslate hb_HHasKey( [<x,...>] )         => HHasKey( <x> )
   #xtranslate hb_HPos( [<x,...>] )            => HGetPos( <x> )
   #xtranslate hb_HGet( [<x,...>] )            => HGet( <x> )
   #xtranslate hb_HSet( [<x,...>] )            => HSet( <x> )
   #xtranslate hb_HDel( [<x,...>] )            => HDel( <x> )
   #xtranslate hb_HKeyAt( [<x,...>] )          => HGetKeyAt( <x> )
   #xtranslate hb_HValueAt( [<x,...>] )        => HGetValueAt( <x> )
   #xtranslate hb_HValueAt( [<x,...>] )        => HSetValueAt( <x> )
   #xtranslate hb_HPairAt( [<x,...>] )         => HGetPairAt( <x> )
   #xtranslate hb_HDelAt( [<x,...>] )          => HDelAt( <x> )
   #xtranslate hb_HKeys( [<x,...>] )           => HGetKeys( <x> )
   #xtranslate hb_HValues( [<x,...>] )         => HGetValues( <x> )
   #xtranslate hb_HFill( [<x,...>] )           => HFill( <x> )
   #xtranslate hb_HClone( [<x,...>] )          => HClone( <x> )
   #xtranslate hb_HCopy( [<x,...>] )           => HCopy( <x> )
   #xtranslate hb_HMerge( [<x,...>] )          => HMerge( <x> )
   #xtranslate hb_HEval( [<x,...>] )           => HEval( <x> )
   #xtranslate hb_HScan( [<x,...>] )           => HScan( <x> )
   #xtranslate hb_HSetCaseMatch( [<x,...>] )   => HSetCaseMatch( <x> )
   #xtranslate hb_HCaseMatch( [<x,...>] )      => HGetCaseMatch( <x> )
   #xtranslate hb_HSetAutoAdd( [<x,...>] )     => HSetAutoAdd( <x> )
   #xtranslate hb_HAutoAdd( [<x,...>] )        => HGetAutoAdd( <x> )
   #xtranslate hb_HAllocate( [<x,...>] )       => HAllocate( <x> )
   #xtranslate hb_HDefault( [<x,...>] )        => HDefault( <x> )
#else
   /* Hash item functions */
   #xtranslate Hash( [<x,...>] )           => hb_Hash( <x> )
   #xtranslate HHasKey( [<x,...>] )        => hb_HHasKey( <x> )
   #xtranslate HGetPos( [<x,...>] )        => hb_HPos( <x> )
   #xtranslate HGet( [<x,...>] )           => hb_HGet( <x> )
   #xtranslate HSet( [<x,...>] )           => hb_HSet( <x> )
   #xtranslate HDel( [<x,...>] )           => hb_HDel( <x> )
   #xtranslate HGetKeyAt( [<x,...>] )      => hb_HKeyAt( <x> )
   #xtranslate HGetValueAt( [<x,...>] )    => hb_HValueAt( <x> )
   #xtranslate HSetValueAt( [<x,...>] )    => hb_HValueAt( <x> )
   #xtranslate HGetPairAt( [<x,...>] )     => hb_HPairAt( <x> )
   #xtranslate HDelAt( [<x,...>] )         => hb_HDelAt( <x> )
   #xtranslate HGetKeys( [<x,...>] )       => hb_HKeys( <x> )
   #xtranslate HGetValues( [<x,...>] )     => hb_HValues( <x> )
   #xtranslate HFill( [<x,...>] )          => hb_HFill( <x> )
   #xtranslate HClone( [<x,...>] )         => hb_HClone( <x> )
   #xtranslate HCopy( [<x,...>] )          => hb_HCopy( <x> )
   #xtranslate HMerge( [<x,...>] )         => hb_HMerge( <x> )
   #xtranslate HEval( [<x,...>] )          => hb_HEval( <x> )
   #xtranslate HScan( [<x,...>] )          => hb_HScan( <x> )
   #xtranslate HSetCaseMatch( [<x,...>] )  => hb_HSetCaseMatch( <x> )
   #xtranslate HGetCaseMatch( [<x,...>] )  => hb_HCaseMatch( <x> )
   #xtranslate HSetAutoAdd( [<x,...>] )    => hb_HSetAutoAdd( <x> )
   #xtranslate HGetAutoAdd( [<x,...>] )    => hb_HAutoAdd( <x> )
   #xtranslate HAllocate( [<x,...>] )      => hb_HAllocate( <x> )
   #xtranslate HDefault( [<x,...>] )       => hb_HDefault( <x> )
   #xtranslate HSetPartition( [<x,...>] )  =>

   /* Associative hash array functions */
   #xtranslate haAGetKeyAt( [<x,...>] )    => hb_HKeyAt( <x> )
   #xtranslate haAGetValueAt( [<x,...>] )  => hb_HValueAt( <x> )
   #xtranslate haADelAt( [<x,...>] )       => hb_HDelAt( <x> )
   #xtranslate haAGetPos( [<x,...>] )      => hb_HPos( <x> )
   #xtranslate haAGetRealPos( <x>, <y> )   => iif( HB_ISNUMERIC( <y> ) .AND. <y> >= 1 .AND. ;
                                                   Int( <y> ) <= Len( <x> ), Int( <y> ), 0 )
   #xtranslate HGetVaaPos( <x> )           => {| h | ;;
                                                LOCAL a := Array( Len( h ), v ;;
                                                FOR EACH v IN a ;;
                                                   v := v:__enumIndex() ;;
                                                NEXT ;;
                                                RETURN a ; }:eval( <x> )
   #xtranslate HGetAACompatibility( <x> )  => hb_HKeepOrder( <x> )
   #xtranslate HSetAACompatibility( [<x,...>] ) => {| h | ;;
                                                   hb_HKeepOrder( h ) ;;
                                                   RETURN .T. ; }:eval( <x> )

#endif
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xHarbour and hash functions

Postby Otto » Fri May 29, 2020 8:59 am

Dear Mr. Rao,
thank you so much.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: xHarbour and hash functions

Postby Otto » Fri Sep 27, 2024 6:19 am

Hello friends,

does someone know how to use

hb_HGetDef() in xHarbour?

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: xHarbour and hash functions

Postby nageswaragunupudi » Mon Sep 30, 2024 12:56 pm

Just use it the same way as you use it in Harbour.
It works
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xHarbour and hash functions

Postby Otto » Mon Sep 30, 2024 7:57 pm

Dear Mr. Rao,

I am sorry, but this errors out:

Code: Select all  Expand view

Embarcadero C++ 7.00 for Win32 Copyright (c) 1993-2015 Embarcadero Technologies, Inc.
C:\FWH\samples\timerdlg.c:
Turbo Incremental Link 6.70 Copyright (c) 1997-2014 Embarcadero Technologies, Inc.
Error: Unresolved external '_HB_FUN_HB_HGETDEF' referenced from C:\FWH\SAMPLES\TIMERDLG.OBJ
 


But I use an old xHarbour version.
Sure, this is the problem. However, updating the production system is always a challenge.
(Never change a winning team.)
I am now using a workaround with HHasKey() + valtype().

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: xHarbour and hash functions

Postby Otto » Mon Sep 30, 2024 8:06 pm

Dear Mr. Rao,

as a supplement to my previous email.
Since I need this function for the new microservice, I think it will be easiest to switch this project, which is still very small, to Harbour. I'll do that.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: xHarbour and hash functions

Postby nageswaragunupudi » Tue Oct 01, 2024 1:21 am

I have this version of xHarbour.
xHarbour 1.2.3 Intl. (SimpLex) (Build 20161218)

Everything is working well with this version. ( including xHarbour + harupdf issue reported in these forums)

I can send this version to you. I am sure you will not have any issues. Please try
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xHarbour and hash functions

Postby Otto » Tue Oct 01, 2024 7:21 am

Dear Mr. Rao,

Thank you. It would be kind if you could provide me with a download link.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: xHarbour and hash functions

Postby Enrico Maria Giordano » Tue Oct 01, 2024 9:00 am

nageswaragunupudi wrote:I have this version of xHarbour.
xHarbour 1.2.3 Intl. (SimpLex) (Build 20161218)


Please update your xHarbour release. You cannot work with such an old version.
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 58 guests