xsharp.eu • Why does a call to a X# DLL from VO require a parameter?
Page 1 of 1

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

Posted: Mon Sep 03, 2018 1:03 pm
by ic2
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

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

Posted: Mon Sep 03, 2018 1:08 pm
by wriedmann
Hi Dick,

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

Wolfgang

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

Posted: Mon Sep 03, 2018 1:19 pm
by ic2
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

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

Posted: Mon Sep 03, 2018 1:28 pm
by Chris
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

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

Posted: Mon Sep 03, 2018 1:30 pm
by wriedmann
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:

Code: Select all

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

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

Posted: Mon Sep 03, 2018 1:44 pm
by ic2
Hello Chris Wolfgang,

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

Dick