fbpx

Why does a call to a X# DLL from VO require a parameter?

More
4 months 2 weeks ago #1 by Dick
Consider this:

In our X #DLL which we call from VO, we have this function:

METHOD DoSomething(n1 as dword) AS DWORD
LOCAL n1 AS DWORD
DoSomethingElse()
RETURN n1

From VO we call it like this:

oXS:= OLEAutoObject{"IC2ExtLibForVO.VOVulcanClass"}

IF oXS:finit
oXS:DoSomething(1)

This ends up in a run time error if we leave out the parameter in red (and assign n1 locally as in green); the catched error message says that the number of parameters is incorrect. n1 has no function. If we pass the parameter in red, it works.

Why does the call to a X# method from VO require a parameter?

Dick

Please Log in or Create an account to join the conversation.

More
4 months 2 weeks ago #2 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Why does a call to a X# DLL from VO require a parameter?
Hi Dick,

probably the OLE method you use in VO defines that there is one int parameter.

Wolfgang

Please Log in or Create an account to join the conversation.

More
4 months 2 weeks ago #3 by Dick
Hello Wolfgang,

That's what I call a quick reply!

But I'm not sure where you are referring too. DoSomething is the method (in the X# DLL) I call. It works with 1 parameter and also with >1. Only not with 0 (with or without parenthesis) . I'm not sure what this has to do with the VO defines?

Dick

Please Log in or Create an account to join the conversation.

More
4 months 2 weeks ago #4 by Chris Pyrgas
Dick, I suspect you have enabled the /vo5 (implicit CLIPPER calling convention) option in your X# library? This will make the method under the hood actually have one hidden parameter, this is important for implementing CLIPPER calling convention. To make sure you avoid this, no matter the compiler options, just explicitly define the method as STRICT:

METHOD DoSomething() AS DWORD STRICT

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

More
4 months 2 weeks ago #5 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Why does a call to a X# DLL from VO require a parameter?
Hi Dick,

your X# library is used in VO via COM.

To call it from VO, you have generated an interface class. In this class, every method defines the number and type of variables:
METHOD Process(;
		cSubject,;		// AS STRING
		cMailBody,;		// AS STRING
		lIsHTML;		// AS LOGIC
		) CLASS ISmtpSender

	LOCAL oMethod  	AS cOleMethod
	LOCAL uRetValue	AS USUAL

	oMethod		      	:= cOleMethod{}
	oMethod:symName	  	:= String2Symbol("Process")
	oMethod:iMemberid  	:= 105 
	oMethod:wInvokeKind	:= INVOKE_METHOD  
	oMethod:nParams    	:= 3 
	oMethod:lNamedArgs 	:= TRUE 
	oMethod:cParamTypes	:= VTS_BSTRW + VTS_BSTRW + VTS_BOOL 
	oMethod:bRetType   	:= VT_BOOL 

	uRetValue := SELF:__Invoke(oMethod, DWORD(_BP+16),PCount())

	RETURN (uRetValue)

If you change the code on the X# side, you must regenerate the code also on the VO side, or at least adjust it (Normally, I do the latter).

Wolfgang

Please Log in or Create an account to join the conversation.

More
4 months 2 weeks ago #6 by Dick
Hello Chris Wolfgang,

Thanks for the replies. Indeed adding STRICT solved the problem! Now it works without parameter.

Dick

Please Log in or Create an account to join the conversation.