DLL32 definition with double parameter type
- Massimo Linossi
- Posts: 474
- Joined: Mon Oct 17, 2005 10:38 am
- Location: Italy
DLL32 definition with double parameter type
Hi.
It is possible to define a double type parameter in the DLL32 definition ?
I have this function to call for retrieving a Double field into an Advantage Database table.
DLL32 Function AdsGetDouble (phTable AS LONG, pucFldName AS LPSTR, @pdValue AS LONG) ;
AS LONG PASCAL FROM "AdsGetDouble" LIB "ACE32.DLL"
The pdValue is a Double field. With the LONG definition I'm losing the decimals.
Thanks a lot.
Massimo
It is possible to define a double type parameter in the DLL32 definition ?
I have this function to call for retrieving a Double field into an Advantage Database table.
DLL32 Function AdsGetDouble (phTable AS LONG, pucFldName AS LPSTR, @pdValue AS LONG) ;
AS LONG PASCAL FROM "AdsGetDouble" LIB "ACE32.DLL"
The pdValue is a Double field. With the LONG definition I'm losing the decimals.
Thanks a lot.
Massimo
Re: DLL32 definition with double parameter type
You are tried?DLL32 Function AdsGetDouble (phTable AS LONG, pucFldName AS LPSTR, @pdValue AS LONG)
Code: Select all
DLL32 Function AdsGetDouble (phTable AS LONG, pucFldName AS LPSTR, @pdValue AS _DOUBLE )
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
- Massimo Linossi
- Posts: 474
- Joined: Mon Oct 17, 2005 10:38 am
- Location: Italy
Re: DLL32 definition with double parameter type
Hi.
I receive an error.
5021 : The pointer given was not valid.
Thanks a lot for your suggestion.
I receive an error.
5021 : The pointer given was not valid.
Thanks a lot for your suggestion.
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- Massimo Linossi
- Posts: 474
- Joined: Mon Oct 17, 2005 10:38 am
- Location: Italy
Re: DLL32 definition with double parameter type
Hi.
Now there is no error but I get a strange result.
Inside the table field the value is 729.29 but with this code I get -343597384
value = 0.00
AdsGetDouble(handle, "IMPORTO", @value)
msginfo(value)
Many thanks for your help.
Massimo
Now there is no error but I get a strange result.
Inside the table field the value is 729.29 but with this code I get -343597384
value = 0.00
AdsGetDouble(handle, "IMPORTO", @value)
msginfo(value)
Many thanks for your help.
Massimo
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: DLL32 definition with double parameter type
So you have to use AS LPSTR and convert the content of the string to the required value.
EMG
EMG
- Massimo Linossi
- Posts: 474
- Joined: Mon Oct 17, 2005 10:38 am
- Location: Italy
Re: DLL32 definition with double parameter type
I've tried but with LPSTR the return of the function call is
always 5021 : The pointer given was not valid.
always 5021 : The pointer given was not valid.
Re: DLL32 definition with double parameter type
Please, Can you try with?Massimo Linossi wrote:Hi.
It is possible to define a double type parameter in the DLL32 definition ?
I have this function to call for retrieving a Double field into an Advantage Database table.
DLL32 Function AdsGetDouble (phTable AS LONG, pucFldName AS LPSTR, @pdValue AS LONG) ;
AS LONG PASCAL FROM "AdsGetDouble" LIB "ACE32.DLL"
The pdValue is a Double field. With the LONG definition I'm losing the decimals.
Thanks a lot.
Massimo
DLL32 Function AdsGetDouble (phTable AS LONG, pucFldName AS LPSTR, @pdValue AS LONGLONG) ;
AS LONG PASCAL FROM "AdsGetDouble" LIB "ACE32.DLL"
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
- Massimo Linossi
- Posts: 474
- Joined: Mon Oct 17, 2005 10:38 am
- Location: Italy
Re: DLL32 definition with double parameter type
Hi.
Now I have a compiler error :
main.prg(463) Warning W0001 Ambiguous reference: 'LONGLONG'
Now I have a compiler error :
main.prg(463) Warning W0001 Ambiguous reference: 'LONGLONG'
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: DLL32 definition with double parameter type
Can I see the complete sample, please?Massimo Linossi wrote:I've tried but with LPSTR the return of the function call is
always 5021 : The pointer given was not valid.
EMG
- Massimo Linossi
- Posts: 474
- Joined: Mon Oct 17, 2005 10:38 am
- Location: Italy
Re: DLL32 definition with double parameter type
Hi Enrico.
Here is the code. Thanks a lot for your time.
Here is the code. Thanks a lot for your time.
Code: Select all
#include "fivewin.ch"
#include "c:\xHb\include\ads.ch"
STATIC Ads_Handle, nreturn, handle, handle_index, stringa, stringaUTF, finefile
PROCEDURE Main
LOCAL importo_tot
LOCAL ora_inizio, ora_fine
local aFields:={} , aFile:="C:\TEMP\TEST", bFile:="C:\TEMP\CONTEGGI", contatore:=0
local ora_inizio, ora_fine
LOCAL pucBuf
LOCAL pucBufLen
LOCAL handle, handle_index, tot_records, conta_records
LOCAL COD_UTENTE, IMPORTO
SET DELETED ON
SET CENTURY ON
SET CONFIRM ON
SET DATE BRITISH
SET _3DLOOK ON
SET EPOCH TO 1990
SET EXCLUSIVE OFF
REQUEST HB_LANG_IT
HB_LANGSELECT("IT")
REQUEST ADS
REQUEST RMDBFCDX
REQUEST DBFFPT
rddRegister( "ADS", 1 )
rddsetdefault( "ADS" )
SET SERVER REMOTE
SET FILETYPE TO ADT
SET(_SET_AUTORDER,1)
SET AUTOPEN ON
set(_SET_OPTIMIZE,.F.)
ADSLOCKING(.F.)
eval({||sethandlecount( 120 )})
IF !AdsConnect60("C:\ARCHIVI\DATABASE.ADD", 7, "login", "password", , @Ads_Handle)
MsgStop("Il database non è connesso." , "Attenzione")
Return
ENDIF
AdsConnection(Ads_Handle)
ora_inizio = time()
aadd(aFields, { "COD_UTENTE" , "C" , 10 , 0 })
aadd(aFields, { "TOTALE" , "N" , 12 , 2 })
Ferase(afile + ".DBF")
DbCreate( afile , aFields , "RMDBFCDX" )
USE (aFile) ALIAS APPO EXCLUSIVE NEW VIA "RMDBFCDX"
USE (bFile) ALIAS CONTEGGI SHARED NEW READONLY VIA "RMDBFCDX"
AdsOpenTable90(Ads_Handle, "IMPORTI", "IMPORTI", 0, 1, 0, 1, 2, ,@handle )
AdsGetIndexHandle(handle, "COD_UTENTE", @handle_index )
sele conteggi
Dbgotop()
Do While !eof()
importo_tot = 0
AdsClearScope(handle_index, 1)
AdsClearScope(handle_index, 2)
AdsSetScope(handle_index, 1, conteggi->COD_UTENTE, 10, 2)
AdsSetScope(handle_index, 2, conteggi->COD_UTENTE, 10, 2)
AdsGotoTop(handle_index)
AdsGetRecordCount(handle_index, 3, @tot_records)
conta_records = 0
do while .t.
IMPORTO = 0.00
nReturn = AdsGetDouble(handle, "IMPORTO", @IMPORTO)
*
* here nReturn = 5021 ; the pointer given was not valid
* importo = 0
importo_tot += round(IMPORTO,2)
AdsSkip(handle, 1)
conta_records ++
if conta_records > tot_records
exit
endif
enddo
contatore ++
Select Appo
DbAppend()
Appo->COD_UTENTE = conteggi->COD_UTENTE
Appo->TOTALE = importo_tot
Select conteggi
DbSkip()
Enddo
AdsCloseindex(handle_index)
AdsCloseTable(handle)
ora_fine = time()
Dbcloseall()
MSGINFO(ora_inizio + " " + ora_fine,str(contatore))
AdsDisconnect(Ads_Handle)
AdsApplicationExit()
quit
Return
DLL32 Function Type_AdsGetConnection(adshandle as LONG) ;
AS LONG PASCAL FROM "AdsGetConnectionType" LIB "ACE32.DLL"
DLL32 Function Create_sql(hConnect as LONG, @phStatement as LONG) ;
AS LONG PASCAL FROM "AdsCreateSQLStatement" LIB "ACE32.DLL"
DLL32 Function Close_sql(hStatement as LONG) ;
AS LONG PASCAL FROM "AdsCloseSQLStatement" LIB "ACE32.DLL"
DLL32 Function ADS_DateFormat(stringa_test As LPSTR, @adshandle as LONG) ;
AS LONG PASCAL FROM "AdsGetDateFormat" LIB "ACE32.DLL"
DLL32 Function Verify_Ads(hStatement as LONG, @pucSQL As LPSTR) ;
AS LONG PASCAL FROM "AdsVerifySQL" LIB "ACE32.DLL"
DLL32 Function Error_Ads(@pulErrorCode As LONG, @pucBuf As LPSTR, @pucBufLen As LONG) ;
AS LONG PASCAL FROM "AdsGetLastError" LIB "ACE32.DLL"
DLL32 Function AdsOpenTable(hConnect AS LONG, pucName AS LPSTR, pucAlias AS LPSTR, usTableType AS LONG, usCharType AS LONG, usLockType AS LONG, usCheckRights AS LONG, ulOptions AS LONG, @phTable AS LONG) ;
AS LONG PASCAL FROM "AdsOpenTable" LIB "ACE32.DLL"
DLL32 Function AdsOpenTable90(hConnect AS LONG, pucName AS LPSTR, pucAlias AS LPSTR, usTableType AS LONG, usCharType AS LONG, usLockType AS LONG, usCheckRights AS LONG, ulOptions AS LONG, pucCollation as LONG, @phTable AS LONG) ;
AS LONG PASCAL FROM "AdsOpenTable90" LIB "ACE32.DLL"
DLL32 Function AdsOpenIndex(hTable AS LONG, pucName AS LPSTR, @ahIndex AS LPSTR, @pusArrayLen AS LPSTR ) ;
AS LONG PASCAL FROM "AdsOpenIndex" LIB "ACE32.DLL"
DLL32 Function AdsGetAllIndexes(hTable AS LONG, @ahIndex AS LPSTR, pusArrayLen AS LPSTR ) ;
AS LONG PASCAL FROM "AdsGetAllIndexes" LIB "ACE32.DLL"
DLL32 Function AdsGetIndexHandle(hTable AS LONG, pucIndexOrder AS LPSTR, @phIndex AS LONG ) ;
AS LONG PASCAL FROM "AdsGetIndexHandle" LIB "ACE32.DLL"
DLL32 Function AdsSetScope(hIndex AS LONG, usScopeOption AS LONG, @pucScope AS LPSTR, usScopeLen AS LONG, usDataType AS LONG ) ;
AS LONG PASCAL FROM "AdsSetScope" LIB "ACE32.DLL"
DLL32 Function AdsClearScope(hIndex AS LONG, usScopeOption AS LONG ) ;
AS LONG PASCAL FROM "AdsClearScope" LIB "ACE32.DLL"
DLL32 Function AdsGetRecordCount(hObj AS LONG, usFilterOption AS LONG, @pulCount AS LONG ) ;
AS LONG PASCAL FROM "AdsGetRecordCount" LIB "ACE32.DLL"
DLL32 Function AdsGoTop (phTable AS LONG) ;
AS LONG PASCAL FROM "AdsGoTop" LIB "ACE32.DLL"
DLL32 Function AdsGotoTop (phTable AS LONG) ;
AS LONG PASCAL FROM "AdsGotoTop" LIB "ACE32.DLL"
DLL32 Function AdsGotoRecord (phTable AS LONG, ulRec AS LONG) ;
AS LONG PASCAL FROM "AdsGotoRecord" LIB "ACE32.DLL"
DLL32 Function AdsSkip (phTable AS LONG, ulRec AS LONG) ;
AS LONG PASCAL FROM "AdsSkip" LIB "ACE32.DLL"
DLL32 Function AdsGetField (hTable AS LONG, pucFldName AS LPSTR, @pucBuf AS LPSTR, pulLen AS LONG, usOption AS LONG) ;
AS LONG PASCAL FROM "AdsGetField" LIB "ACE32.DLL"
DLL32 Function AdsGetFieldW (hTable AS LONG, pucFldName AS LPSTR, @pwcBuf AS LPSTR, pulLen AS LONG, usOption AS LONG) ;
AS LONG PASCAL FROM "AdsGetFieldW" LIB "ACE32.DLL"
DLL32 Function AdsGetLong (hTable AS LONG, pucFldName AS LPSTR, @plValue AS LONG) ;
AS LONG PASCAL FROM "AdsGetLong" LIB "ACE32.DLL"
DLL32 Function AdsGetDouble (hTable AS LONG, pucFldName AS LPSTR, @pdValue AS LPSTR) ;
AS LONG PASCAL FROM "AdsGetDouble" LIB "ACE32.DLL"
DLL32 Function AdsGetRecord (hTable AS LONG, @pucRec AS LPSTR, @pucLen AS LONG) ;
AS LONG PASCAL FROM "AdsGetRecord" LIB "ACE32.DLL"
DLL32 Function AdsGetRecordLength (hTable AS LONG, @pucLen AS LONG) ;
AS LONG PASCAL FROM "AdsGetRecordLength" LIB "ACE32.DLL"
DLL32 Function AdsCacheRecords (phTable AS LONG, @usRecords AS LONG) ;
AS LONG PASCAL FROM "AdsCacheRecords" LIB "ACE32.DLL"
DLL32 Function AdsAtEOF (phTable AS LONG, @pbEof AS LONG) ;
AS LONG PASCAL FROM "AdsAtEOF" LIB "ACE32.DLL"
DLL32 Function AdsGetString (phTable AS LONG, pucFldName AS LPSTR, @pucbuf AS LPSTR, @pwcbuf AS LPSTR, pulLen AS LONG, usOption as LONG ) ;
AS LONG PASCAL FROM "AdsGetString" LIB "ACE32.DLL"
DLL32 Function AdsCloseTable (phTable AS LONG) ;
AS LONG PASCAL FROM "AdsCloseTable" LIB "ACE32.DLL"
DLL32 Function AdsCloseIndex (phTable AS LONG) ;
AS LONG PASCAL FROM "AdsCloseIndex" LIB "ACE32.DLL"
Last edited by Massimo Linossi on Mon Dec 18, 2017 9:52 am, edited 1 time in total.
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: DLL32 definition with double parameter type
The error is here:
You have to make a string buffer of the right length for a double and then store in it the binary value for 0.00.
EMG
Code: Select all
IMPORTO = 0.00
EMG
- Massimo Linossi
- Posts: 474
- Joined: Mon Oct 17, 2005 10:38 am
- Location: Italy
Re: DLL32 definition with double parameter type
Hi Enrico.
With this code nReturn is 0 (correct) but IMPORTO is -343597384
IMPORTO = "0.00"
nReturn = AdsGetDouble(handle, "IMP_FORN", @IMPORTO)
msginfo(IMPORTO, str(nReturn))
With this code nReturn is 0 (correct) but IMPORTO is -343597384
IMPORTO = "0.00"
nReturn = AdsGetDouble(handle, "IMP_FORN", @IMPORTO)
msginfo(IMPORTO, str(nReturn))
Re: DLL32 definition with double parameter type
Tengo una DLL escrita en c # y tengo un ejemplo de consumir esta función que esta en la DLL de C # en Delphi, ahora prefiero consumir esta misma función en xHarbour, alguien podría ayudarme.
Code: Select all
Ret := TCertfly.Assinar('C:\xml\R1000_N.xml', 'C:\xml\R1000_ASS.xml', 'MinhaTag','0', '1ce63d4dcefb45e9', '1234');
if Ret = 0 then
ShowMessage('Sucesso')
else
ShowMessage('False');
end;
end.
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: DLL32 definition with double parameter type
Massimo Linossi wrote:Hi Enrico.
With this code nReturn is 0 (correct) but IMPORTO is -343597384
IMPORTO = "0.00"
nReturn = AdsGetDouble(handle, "IMP_FORN", @IMPORTO)
msginfo(IMPORTO, str(nReturn))
Code: Select all
IMPORTO = "0.00"
- create a string with the right length for the double value required by the function (8 bytes?)
- put in that string the binary value of 0.00, not the string value (8 CHR( 0 )s?)
EMG