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

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

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

Post 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
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

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

Post by wriedmann »

Hi Dick,

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

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

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

Post 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
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

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

Post 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
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

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

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

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

Post by ic2 »

Hello Chris Wolfgang,

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

Dick
Post Reply