DLL32 definition with double parameter type

Re: DLL32 definition with double parameter type

Postby Massimo Linossi » Mon Dec 18, 2017 1:00 pm

Placing a replicate(chr(0),8) in the importo variable I have the same result.

Looking inside the ADS documentation I found this :

AdsGetLong
Retrieves the long integer value from the given field.
Syntax

UNSIGNED32
AdsGetLong (ADSHANDLE hTable,
UNSIGNED8 *pucFldName,
SIGNED32 *plValue);

Parameters
hTable (I)
Handle of table or cursor.

pucFldName (I)
Name of field to retrieve.

plValue (O)
Return the value.

Special Return Codes
AE_NO_CURRENT_RECORD

Data cannot be retrieved from EOF or BOF.

Remarks
AdsGetLong returns the signed long value stored in the numeric, integer, short integer, double, CurDouble, RowVersion, or auto-increment field. It is possible to either overflow the value or lose decimal precision by using this function. If more precision is desired, use AdsGetDouble. When using this function to retrieve an auto-increment value, be sure to treat the result as an unsigned value. If AdsGetLong is used to retrieve a Money field, the four decimal digits will be rounded to the nearest whole number.
The pucFldName parameter can be passed as the field name itself or as the one-based integer field position. To pass an integer field position for the pucFldName parameter, use the ADSFIELD macro that is defined in ACE.H. For example, to specify the first field in the table, pass ADSFIELD(1) for the pucFldName parameter; to specify the second field in the table, pass ADSFIELD(2) for the pucFldName parameter; etc.
User avatar
Massimo Linossi
 
Posts: 500
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: DLL32 definition with double parameter type

Postby Enrico Maria Giordano » Mon Dec 18, 2017 1:06 pm

Massimo Linossi wrote:Placing a replicate(chr(0),8) in the importo variable I have the same result.


Probably it's not the right binary representation for 0 double value the function is expecting. There is any mention in the docs about the expected double format?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: DLL32 definition with double parameter type

Postby Massimo Linossi » Mon Dec 18, 2017 3:29 pm

The only documentation I found is that I wrote 2 messages ago.
There is not so much about this on their forum too.
Thanks a lot.
Massimo
User avatar
Massimo Linossi
 
Posts: 500
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: DLL32 definition with double parameter type

Postby Enrico Maria Giordano » Mon Dec 18, 2017 5:59 pm

So, let's assume that the doubles are in Microsoft format (can we?). You have to assign this way:

Code: Select all  Expand view  RUN
IMPORTO = L2BIN( NDBL2FLT( 0 ) )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: DLL32 definition with double parameter type

Postby Massimo Linossi » Tue Dec 19, 2017 8:19 am

Hi Enrico.
With this code I have this result :

IMPORTO = L2BIN( NDBL2FLT( 0 ))
nReturn = AdsGetDouble(handle, "IMPORTO", @IMPORTO)
msginfo(IMPORTO, str(nReturn))

Image
User avatar
Massimo Linossi
 
Posts: 500
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: DLL32 definition with double parameter type

Postby Enrico Maria Giordano » Tue Dec 19, 2017 9:40 am

Now you have to convert back from binary to numeric value. Use this function:

Code: Select all  Expand view  RUN
HB_FUNC( NFLT2DBL )
{
    float nVal;

    const char *cPar = hb_parc( 1 );
    char *cVal = ( char * ) &nVal;

    cVal[ 0 ] = cPar[ 0 ];
    cVal[ 1 ] = cPar[ 1 ];
    cVal[ 2 ] = cPar[ 2 ];
    cVal[ 3 ] = cPar[ 3 ];

    hb_retndlen( nVal, 15, 6 );
}


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: DLL32 definition with double parameter type

Postby Massimo Linossi » Tue Dec 19, 2017 12:09 pm

Hi.
With the function changed like this, I have this result :

IMPORTO = L2BIN( NDBL2FLT( 0 ))
nReturn = AdsGetDouble(handle, "IMPORTO", @IMPORTO)
msginfo(NFLT2DBL(IMPORTO), str(nReturn))

Image
User avatar
Massimo Linossi
 
Posts: 500
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: DLL32 definition with double parameter type

Postby Enrico Maria Giordano » Tue Dec 19, 2017 12:49 pm

Probably the DLL function doesn't use the Microsoft format.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: DLL32 definition with double parameter type

Postby Massimo Linossi » Tue Dec 19, 2017 4:17 pm

You're right.
I surrender. Thanks a lot for your time.
Massimo
User avatar
Massimo Linossi
 
Posts: 500
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

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