Not able to pass long to non jde function

manther

Active Member
This is probably so simple but I could use a second pair of eyes. I'm having a problem passing the 6th argument the long. "li"
Here's my JDE info:
EnterpriseOne tools release 8.94.L1, OS 2003 R2, SQL server 2000.
E1 release 8.10

The compile error I'm getting is:
C:\E810\PD810\source\B550002.c(57) : error C2115: 'function' : incompatible types
C:\E810\PD810\source\B550002.c(57) : warning C4024: 'lpfnDLL_Test' : different types for formal and actual parameter 6


Here is the non JDE function:

<font class="small">Code:</font><hr /><pre> // Dll_test.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "Dll_test.h"
#import "C:\MyInterop\MyInterop\bin\Debug\com.MyInterop.tlb" named_guids raw_interfaces_only

DLL_TEST_API void SubmitCC(BSTR sNameOnCard, BSTR sCCNumber, BSTR sExpDate, BSTR sCvv, BSTR sAmount, long lDonorID, BSTR *pRetVal);

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}


//Shares out the .NET methos SubmitCC
DLL_TEST_API void SubmitCC(BSTR sNameOnCard, BSTR sCCNumber, BSTR sExpDate, BSTR sCvv, BSTR sAmount, long lDonorID, BSTR *pRetVal)
{
MyInterop::IPaymentProcessInterfacePtr pPaymentPtr;
HRESULT hRes = pPaymentPtr.CreateInstance(MyInterop::CLSID_PaymentProcess);

if (hRes == S_OK)
{
HRESULT hr = pPaymentPtr->SubmitCC(sNameOnCard, sCCNumber, sExpDate, sCvv, sAmount, lDonorID, pRetVal);

if(hr == S_OK)
{
//return *pRetVal;
}
}
// return NULL;
}

// This is an example of an exported variable
DLL_TEST_API int nDll_test=0;


// This is the constructor of a class that has been exported.
// see Dll_test.h for the class definition
CDll_test::CDll_test()
{
return;
}
</pre><hr />
Here is the JDE business function that calls the function listed on top.

<font class="small">Code:</font><hr /><pre>
/*********************************************************************
* Notes:
* Generated from OneWorld Event Rules
*
*********************************************************************/

#include <jde.h>
#include <B550002.h>


/*********************************************************************
* Business Function Prototypes
*********************************************************************/

JDEBFRTN(ID) JDEBFWINAPI
CBusinessFunctionExample( LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5500CC lpDS )
{
//# ifdef JDENV_PC
/**********************
* Variable declarations
***********************/
//BSTR * bStrn = NULL;
//int nMathReturn = MATH_SUCCESS;
/******************************
*Declare pointers
******************************/
PFNDLL_TEST lpfnDLL_Test;
HINSTANCE hLibrary;
/*****************************
*Check for null pointers
*****************************/
if( (lpBhvrCom == (LPBHVRCOM) NULL) ||
(lpVoid == (LPVOID) NULL) ||
(lpDS == (LPDSD5500CC) NULL))
{
jdeErrorSet (lpBhvrCom, lpVoid, 0L , _J("4363"), (LPVOID) NULL);
return ER_ERROR;
}
/*****************************
*Set pointers
*****************************/
lpfnDLL_Test = (PFNDLL_TEST) NULL;
hLibrary = (HINSTANCE) NULL;
/**************************
*Main processing
**************************/
hLibrary = LoadLibrary(_J("C:\\Dll_test\\Debug\\Dll_test.dll"));
if(hLibrary)
{
lpfnDLL_Test = (PFNDLL_TEST) GetProcAddress (hLibrary, _J("?SubmitCC@@YAXPAG0000JPAPAG@Z"));
if( lpfnDLL_Test )
{
<font color="red">unsigned long li;
//li = atol (lpDS->mnDonorID->);
MathNumericToLong(&lpDS->mnDonorID, (long *)&li);
//lpDS->szReturn = '\0';
lpfnDLL_Test( (ushort *)lpDS->szNameOnCard, (ushort *)lpDS->szCCNum, (ushort *)lpDS->szEXP, (ushort *)lpDS->szCvv, (ushort *)lpDS->szAmount, <font color="green">li</font>, (ushort*)&lpDS->szReturn);
//jdeStrcpy(lpDS->szReturn, (CONST JCHAR*)lpDS->szReturn);</font>
}
FreeLibrary (hLibrary);
}
/*********************************
*Function Cleanup
*********************************/
return (ER_SUCCESS);
}
</pre><hr />
Thanks any help is appriciated. P.S. This I've tried passing the 6 param in many various ways, this is just the way it currently stands.
 
I've edited the original post a ilttle to make it more readable. Least I could do is make it easy for others to help. The section in red in the bottom piece of code is where the problem surfaces. Its there that I trie to call the top section of code. And, the variable in green "li" is where I am attempting to pass the long value.
 
Manther,

Where do you have the PFNDLL_TEST prototype declared? Is it in B550002.h? Can you post that? I'm sure you've tried casting the unsigned long to a long as well, right?
(long)li

Craig
 
Yes sir, thats where it is. Here's the header file:

<font class="small">Code:</font><hr /><pre>
#ifndef __B550001_H
#define __B550001_H
/*********************************************************************
* Global Definitions
*********************************************************************/
#ifdef CER_BOB_MODE
#undef CER_BOB_MODE
#endif
#define CER_BOB_MODE (jdeBitTest(lpObj->dwDialogStatus, \
STATUS_DATA_COPY)?BOB_MODE_COPY:lpBhvrCom->iBobMode)
/******************
*Global definitions
******************/
#ifdef JDENV_PC
#include <windows.h>
typedef int (*PFNDLL_TEST) (JCHAR *szNameOnCard,
JCHAR *szCCNum,
JCHAR *szEXP,
JCHAR *szCvv,
JCHAR *szAmount,
MATH_NUMERIC mnDonorID,
JCHAR *szReturn);
#endif
/********************************
*Structure Definitions
********************************/
/********************************
*DS Template Type Definitions
********************************/
/******************************
* typedef for data structure
******************************
#ifndef DATASTRUCTURE_D550001
#define DATASTRUCTURE_D550001
typedef struct tagDSD550001
{
MATH_NUMERIC mnResult;
} DSD550001, *LPDSD550001;

#define IDERRmnResult_1 1L
#endif
*/
#ifndef DATASTRUCTURE_D5500CC
#define DATASTRUCTURE_D5500CC

typedef struct tagDSD5500CC
{
JCHAR szNameOnCard[125];
JCHAR szCCNum[17];
JCHAR szEXP[10];
JCHAR szCvv[5];
JCHAR szAmount[10];
MATH_NUMERIC mnDonorID;
JCHAR szReturn[125];
} DSD5500CC, *LPDSD5500CC;

#define IDEszNameOnCard 1L
#define IDEszCCNum 2L
#define IDEszEXP 3L
#define IDEszCvv 4L
#define IDEszAmount 5L
#define IDEmnDonorID 6L
#define IDEszReturn 7L
#endif

/*********************************************************************
* Source Preprocessor Definitions
*********************************************************************/
#ifdef JDEBFRTN
#undef JDEBFRTN
#endif
#ifdef WIN32
#define JDEBFRTN(r) __declspec(dllexport) r
#else
#define JDEBFRTN(r) r
#endif

/*********************************************************************
* Business Function Prototypes
*********************************************************************/

JDEBFRTN(ID) JDEBFWINAPI
CBusinessFunctionExample( LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5500CC lpDS );
#endif
</pre><hr />
 
Manther,

typedef int (*PFNDLL_TEST) (JCHAR *szNameOnCard, JCHAR* szCCNum, JCHAR *szEXP, JCHAR *szCvv, JCHAR *szAmount, MATH_NUMERIC mnDonorID, JCHAR* szReturn);

Parm six is a MATH_NUMERIC in the typedef but the actual function parm is a long and what your passing to it in code. Changing the above in the header file to a long should at least get it to compile.

Craig
 
OK cool! I'm gonna try that. It was confusing because I didn't think JDE would know what a long was. Is this the structure that JDE passes it's data to from it's JDE structure I designed for my business function?
 
The typedef for PFNDLL_TEST is function pointer protoype. When you use GetProcAddress to call a function from a DLL, the returned function pointer is cast to your typedef. This declaration (return type and parameter list) must match exactly what the DLL has exported.
 
Thanks Craig! I got a chance to try this today, and it did resolve the compile issue.

BTW have you ever seen this:
My mathnumeric lpDS->mnDonorID.String contains my ID I'm looking for but not untli the 11th index position. Holds 0x00 in 0-9. Thus my MathNumericToLong doesn't work.
 
JDE's MATH_NUMERIC datatype is a data structure representing numeric data. Generally, you should not manipulate the members yourself. There a many APIs available to get the data you need. I believe you are using
MathNumericToLong(&lpDS->mnDonorID, (long *)&li);
in your BSFN to convert the MATH_NUMERIC to a long and passing that to your wrapper. Does that not work?

Craig
 
No, I wasn't trying to manipulate the members just observing them. But, no MathNumericToLong is not working. And, I thought the peculiarness I observed might have something to do with it. I've included a screenshot:

[image]http://www.asonyo.com/screenShot.bmp[/image]

Notice how the value in the mathnumeric seems to be left padded with zeros? The result of my MathNumericToLong is zero, even though I can see the correct ID value being held with the string property of the data type.
 
Back
Top